Android Question How to open app's specific activity from another app

Blueforcer

Well-Known Member
Licensed User
Longtime User
I want to to open ActivityX in App2 from my App1.

I found this one, but dont know how do do this in B4A

my friend wrote an native application with android studio with an Activity called "SettingsActivity"

XML:
<activity
     android:name=".SettingsActivity"
     android:label="@string/title_activity_settings"
     android:theme="@style/Theme.Template.NoActionBar">
</activity>

I tried several calls but always get errors like
B4X:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10020000 pkg=com.awtrix.template }[/ICODE]

or

[CODE=b4x][ICODE]android.content.ActivityNotFoundException: Unable to find explicit activity class {/.SettingsActivity}; have you declared this activity in your AndroidManifest.xml?[/ICODE]

or

[CODE=b4x]java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10020000 pkg=com.awtrix.template cmp=com.awtrix.template/.SettingsActivity } from ProcessRecord{e674532 8208:com.awtrix.main/u0a545} (pid=8208, uid=10545) not exported from uid 10555
 
Last edited:

Blueforcer

Well-Known Member
Licensed User
Longtime User
Edit: Got it, was a mistake from my friend whos not handle any intent in this activity
 
Last edited:
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
Since its working now with a the native app of my friend, i want to do the same with a b4a app.

he was entering this in his manifest:

XML:
<activity
    android:name=".SettingsActivity"
    android:label="@string/title_activity_settings"
    android:screenOrientation="landscape"
    android:theme="@style/Theme.Template.NoActionBar" >
    <intent-filter>
        <action android:name="android.intent.action.SEND"/>
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</activity>

Now in B4A i add an new Activity with the Name "SettingsActivity"
And add this to my manifest;

B4X:
AddActivityText(SettingsActivity,
<intent-filter>
   <action android:name="android.intent.action.SEND" />
   <category android:name="android.intent.category.DEFAULT" />
</intent-filter>)

unfortunally this dont work.

itry to open it with following code (wich is working with my friends app)

B4X:
Sub openSettingsPage_click
    Dim b As Panel=Sender
    Dim packageName As String= b.Tag
    Dim i As Intent
    Dim pm As PackageManager
    i = pm.GetApplicationIntent(packageName)
    i.SetComponent( packageName & "/.SettingsActivity")
    StartActivity(i)
End Sub


i get the error:
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.awtrix.overwatch/com.awtrix.overwatch.SettingsActivity}; have you declared this activity in your AndroidManifest.xml?


What ive forgot?
 
Upvote 0
Top