I try to launch another app in my app
There is 2 methods I have tried.
Method 1
Intent intent = new Intent(Intent.ACTION_MAIN);
ComponentName componentName = new ComponentName("com.b_app", "com.b_app.MainActivity");
intent.setComponent(componentName);
startActivity(intent);
Method 2
Intent intent = getPackageManager().getLaunchIntentForPackage("com.b_app");
if (intent != null) {
startActivity(intent);//null pointer check in case package name was not found
}
else Toast.makeText(this, "Error", Toast.LENGTH_SHORT).show();
Method 1 gives me error :
Unable to find explicit activity class {com.b_app/com.b_app.MainActivity}; have you declared this activity in your AndroidManifest.xml?
Method 2 the Toast shows Error (my else condition),meaning getPackageManager() returns null..
My Manifest in b_app
<activity android:name="com.b_app.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and I'm pretty sure the b_app is installed in my smartphone..
How can I solve it?