Android Question instagram user profile intent

Ohanian

Active Member
Licensed User
Hi,

B4X:
Sub Process_Globals

Private NativeMe As JavaObject

End Sub

Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
 NativeMe.InitializeContext
End If

NativeMe.RunMethod("OpenInsta", Null)

End Sub

#If JAVA

import android.content.Intent;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
import android.net.Uri;

public void OpenInsta() {
Intent insta_intent = getPackageManager().getLaunchIntentForPackage("com.instagram.android");
insta_intent.setComponent(new ComponentName("com.instagram.android", "com.instagram.android.activity.UrlHandlerActivity"));
insta_intent.setData(Uri.parse("http://instagram.com/p/gjfLqSBQTJ/"));
startActivity(insta_intent);
}
#End If
play with this line for page/profile access :

B4X:
insta_intent.setData(Uri.parse("http://instagram.com/p/gjfLqSBQTJ/"));
 

Mike1970

Well-Known Member
Licensed User
I GOT THIS ERROR

B4A Version: 8.30
Parsing code. (0.02s)
Compiling code. (0.20s)
Compiling layouts code. (0.01s)
Organizing libraries. (0.00s)
Generating R file. (0.62s)
Compiling debugger engine code. (1.22s)
Compiling generated Java code. Error
B4A line: 74
End Sub
javac 1.8.0_151
src\name\hire\main.java:549: error: <identifier> expected
Public void OpenInsta() {
^
1 error
 
Last edited:

Mike1970

Well-Known Member
Licensed User
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 44 (Main)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
at abarbone.hire.main$ResumableSub_Activity_Create.resume(main.java:475)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:735)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:360)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:260)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1680)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:6020)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:936)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:797)
Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.instagram.android/com.instagram.android.activity.UrlHandlerActivity}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1831)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1549)
at android.app.Activity.startActivityForResult(Activity.java:4008)
at android.app.Activity.startActivityForResult(Activity.java:3960)
at android.app.Activity.startActivity(Activity.java:4337)
at android.app.Activity.startActivity(Activity.java:4267)
at abarbone.hire.main.OpenInsta(main.java:555)
... 21 more
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy (ignored)**
 

Mike1970

Well-Known Member
Licensed User
The accepted answer code:
B4X:
Dim in As Intent
in.Initialize(in.ACTION_VIEW, "http://instagram.com/_u/xxx")
Dim jo As JavaObject = in
jo.RunMethod("setPackage", Array("com.instagram.android"))
'Add a Try / Catch block
StartActivity(in)
Thank you Erel.
It perfectly works!
 
Top