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

Jmu5667

Well-Known Member
Licensed 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

Administrator
Staff member
Licensed 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);
       }
   }
 

Jmu5667

Well-Known Member
Licensed 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
 
Top