sktanmoy Active Member Licensed User Longtime User Oct 3, 2018 #1 I was trying to use the code below B4X: #If JAVA public void open_on_instagram(String link){ Uri uri = Uri.parse("http://instagram.com/p/" + link); Intent likeIng = new Intent(Intent.ACTION_VIEW, uri); likeIng.setPackage("com.instagram.android"); try { startActivity(likeIng); } catch (ActivityNotFoundException e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://instagram.com/p/" + link))); } } #End If But the code wasn't being compiled as Uri class was not found. I tried to use the code in B4A way but intent class doesn't have any method called setPackage. setComponent didn't give me the desired result. Can you guys please suggest me what should I do here?
I was trying to use the code below B4X: #If JAVA public void open_on_instagram(String link){ Uri uri = Uri.parse("http://instagram.com/p/" + link); Intent likeIng = new Intent(Intent.ACTION_VIEW, uri); likeIng.setPackage("com.instagram.android"); try { startActivity(likeIng); } catch (ActivityNotFoundException e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://instagram.com/p/" + link))); } } #End If But the code wasn't being compiled as Uri class was not found. I tried to use the code in B4A way but intent class doesn't have any method called setPackage. setComponent didn't give me the desired result. Can you guys please suggest me what should I do here?
Semen Matusovskiy Well-Known Member Licensed User Oct 3, 2018 #2 https://developer.android.com/ Search by Uri. Typically first link is what you need. Uri public abstract class Uri extends Object implements Parcelable, Comparable<Uri> java.lang.Object ↳ android.net.Uri Means you need to add after #If Java import android.net.Uri; Upvote 0
https://developer.android.com/ Search by Uri. Typically first link is what you need. Uri public abstract class Uri extends Object implements Parcelable, Comparable<Uri> java.lang.Object ↳ android.net.Uri Means you need to add after #If Java import android.net.Uri;
Erel B4X founder Staff member Licensed User Longtime User Oct 4, 2018 #3 You don't need this Java code. B4X: Dim in As Intent in.Initialize(in.ACTION_VIEW, "http://instagram.com/p/" & link) Dim jo As JavaObject = in jo.RunMethod("setPackage", Array("com.instagram.android")) 'SetPackage will be included in the next update of B4A StartActivity(in) Upvote 0
You don't need this Java code. B4X: Dim in As Intent in.Initialize(in.ACTION_VIEW, "http://instagram.com/p/" & link) Dim jo As JavaObject = in jo.RunMethod("setPackage", Array("com.instagram.android")) 'SetPackage will be included in the next update of B4A StartActivity(in)