I have a button in my app that launches another app (the user can choose which one with a longClick like this)
btnNavigation.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// Pick an application
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY);
pickIntent.putExtra(Intent.EXTRA_INTENT, mainIntent);
startActivityForResult(pickIntent, 1);
return false;
}
});
with the onActivityResult i get back an intent
Now i’d like to set the image of btnNavigation to the icon of the app the user has chosen
How can i get the icon from the package the user chose?
You can get the a drawable of the application icon like this: