I am considering the code in this question, and did the following:
First, I create a simple, empty project with only one Activity
called MainActivity
, which is in package com.example.plugins
. I compile this project and install it to my device. The app works fine.
Then, in another project I have this code:
Intent plugins = new Intent();
plugins.setClassName("com.example.plugins", "MainActivity");
List<ResolveInfo> list = getPackageManager().queryIntentActivities(plugins,
PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() > 0) {
tvText.setText("Plugins.");
} else {
tvText.setText("No Plugins.");
}
I'd say this should work, but it doesn't. It gives "no plugins". Am I missing something here?
Update When using
PackageInfo pi = getPackageManager().getPackageInfo(
"com.example.plugins", PackageManager.GET_ACTIVITIES);
I do get the activities from that other app.