Android Question [SOLVED] Open an app, intent error

pazzokli

Active Member
Licensed User
Longtime User
Hi, I cannot open an installed app using intent and package name

codice:
Sub OpenApp (applicazione As String)
    Dim i As Intent
    Dim p As PackageManager
    i.Initialize("", "")
    i = p.GetApplicationIntent("com.miui.calculator")
    If i.IsInitialized Then StartActivity(i)
    StartActivity(i)
End Sub

This is log error

log:
main_openapp (java line: 4829)
java.lang.RuntimeException: Object should first be initialized (Intent).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
    at com.domos.client.main._openapp(main.java:4829)
    at com.domos.client.main._btn_camera1_click(main.java:1591)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:7548)
    at android.view.View.performClickInternal(View.java:7525)
    at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
    at android.view.View$PerformClick.run(View.java:29568)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:210)
    at android.os.Looper.loop(Looper.java:299)
    at android.app.ActivityThread.main(ActivityThread.java:8244)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:559)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:954)
 

agraham

Expert
Licensed User
Longtime User
See this post here. You might need a <queries> manifest entry

Also there shouldn't be two StartActivity calls in the code. The one in the check is sufficient.
 
Upvote 0

pazzokli

Active Member
Licensed User
Longtime User
See this post here. You might need a <queries> manifest entry

Also there shouldn't be two StartActivity calls in the code. The one in the check is sufficient.

I solved with this line in the manifest

solution:
AddManifestText(<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>)
 
Upvote 0
Top