Android Question How to add any activity you like with a library like - MainActivity

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hello

How to add any activity you like with a library like - MainActivity so your app call be called by a third party and launch your app with /.MainActivity

any suggestions on how to do this ?

Thanks

John.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Create a library specific to your project with the same package name as your project.

Add the activity declaration to the manifest editor:
B4X:
AddApplicationText(<activity android:name=".MainActivity">
<intent-filter>
              <action android:name="android.intent.action.MAIN" />
              <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
</activity)

The code in the activity should be something like:
B4X:
@Override
   public void onResume() {
       try {
           startActivity(new Intent(this, Class.forName("b4a.example.main")));
       } catch (ClassNotFoundException e) {
           throw new RuntimeException(e);
       }
   }
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
Create a library specific to your project with the same package name as your project.

Add the activity declaration to the manifest editor:
B4X:
AddApplicationText(<activity android:name=".MainActivity">
<intent-filter>
              <action android:name="android.intent.action.MAIN" />
              <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
</activity)

The code in the activity should be something like:
B4X:
@Override
   public void onResume() {
       try {
           startActivity(new Intent(this, Class.forName("b4a.example.main")));
       } catch (ClassNotFoundException e) {
           throw new RuntimeException(e);
       }
   }


Thanks, I'll give it a go
 
Upvote 0
Top