Android Question instagram user profile intent

Discussion in 'Android Questions' started by ™AsAs4242, Jun 24, 2015.

  1. ™AsAs4242

    ™AsAs4242 Member Licensed User

  2. Ohanian

    Ohanian Active Member Licensed User

    Hi,

    Code:
    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 :

    Code:
    insta_intent.setData(Uri.parse("http://instagram.com/p/gjfLqSBQTJ/"));
     
    Blue.Sky and ™AsAs4242 like this.
  3. Mike1970

    Mike1970 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: Aug 26, 2018
  4. Mike1970

    Mike1970 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)**
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    The accepted answer code:
    Code:
    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)
     
  6. Mike1970

    Mike1970 Member Licensed User

    Thank you Erel.
    It perfectly works!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice