Is there a way to start an Activity without knowing its class, for example via an Intent Action?
The background is, I have two Modules, ModuleMain and ModulePushNotification. ModuleMain has a dependency to ModulePushNotification. From ModulePushNotification I want to start an Activity in ModuleMain, but I cannot add a dependency ModulePushNotification -> ModuleMain because this would produce a circular dependency.
Therefore, I cannot start the activity this way:
startActivity(new Intent(this, Main.class));
I tried to start the Activity using an Intent Action:
Intent intent = new Intent("com.android.main.MY_MAIN");
intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivity(intent);
... with this Manifest in ModuleMain:
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="com.android.main.MY_MAIN" />
<category android:name="ANDROID.INTENT.CATEGORY.DEFAULT" />
</intent-filter>
</activity>
... but this produces the Exception:
Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.android.main.MY_MAIN cat=[android.intent.category.DEFAULT]
Is there a way to start the main activity of the app, without restructuring the project/dependencies?
Aucun commentaire:
Enregistrer un commentaire