using Intent is B4A

DevBaby

Active Member
Licensed User
Longtime User
I have never used this before, however...

The android developer site shows how to launch the android store with a link to your app, from within an app. Their code is below

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.example.android"));
startActivity(intent);

Can anyone direct me to find out how this is done using B4A?
 

laiberica

Member
Licensed User
Longtime User
Hello, could you helpme with this?
I need write this in B4A

Intent intent = new Intent("com.sec.print.mobileprint.action.PRINT");
Uri uri = Uri.parse(“http://www.samsung.com");
intent.putExtra("com.sec.print.mobileprint.extra.CONTENT", uri );
intent.putExtra("com.sec.print.mobileprint.extra.CONTENT_TYPE", “WEBPAGE");
intent.putExtra("com.sec.print.mobileprint.extra.OPTION_TYPE", “DOCUMENT_PRINT");
intent.putExtra("com.sec.print.mobileprint.extra.JOB_NAME", "Untitled");
startActivity(intent);

I write this but it doesnt work: (I think the problem is with the 2nd line, i dont know how translate it, where say "uri")

Dim Intent1 As Intent
Intent1.Initialize("com.sec.print.mobileprint.action.PRINT", "http://www.samsung.com")
Intent1.putExtra("com.sec.print.mobileprint.extra.CONTENT_TYPE", "WEBPAGE")
Intent1.putExtra("com.sec.print.mobileprint.extra.OPTION_TYPE", "DOCUMENT_PRINT")
Intent1.putExtra("com.sec.print.mobileprint.extra.JOB_NAME", "Untitled")
StartActivity(Intent1)
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
Try this:
B4X:
Dim Intent1 As Intent

Intent1.Initialize("com.sec.print.mobileprint.action.PRINT", "")
Intent1.PutExtra("com.sec.print.mobileprint.extra.CONTENT", ParseUri("http://www.samsung.com"))
Intent1.putExtra("com.sec.print.mobileprint.extra.CONTENT_TYPE", "WEBPAGE")
Intent1.putExtra("com.sec.print.mobileprint.extra.OPTION_TYPE", "DOCUMENT_PRINT")
Intent1.putExtra("com.sec.print.mobileprint.extra.JOB_NAME", "Untitled")

StartActivity(Intent1)


....

Sub ParseUri(s As String) As Object

    Dim r As Reflector
    
    Return r.RunStaticMethod("android.net.Uri", "parse", Array As Object(s), Array As String("java.lang.String"))
				
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…