Search code examples
androidsecurityexceptionstart-activity

Starting a no launcher activity from another package


I try to start an activity from another package, but it has not LAUNCHER category

Intent i = new Intent();            
i.setComponent(new ComponentName(maxVerPackageName, maxVerClassName));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  
startActivity(i);

I faced the Exception: "An exception occurred: java.lang.SecurityException"

what's wrong, please help?


Solution

  • The other activity is enforcing a permission. So that only apps that have the permission or same uid can launch the activity.

    Edit: If you have written other app

    then add this attribute to the other activity which you are trying to launch

    android:exported="true"