I made an Activity to choose an app from the installed apps and get the launcher intent of the selected app and pass that intent back to an the starting Activity:
Intent intent = packageManager
.getLaunchIntentForPackage(app.packageName);
if (null != intent) {
Intent data = new Intent();
data.setData(Uri.parse(intent.toString()));
setResult(RESULT_OK, data);
finish();
}
onActivityResult from the starting Activity:
public void onActivityResult(int requestCode, int resultCode, Intent data){
if (requestCode == request_Code){
if (resultCode == RESULT_OK){
intent = data.getData().toString();
startActivity(new Intent(intent));
}
I extracted intent
String and the Intent
inside startActivity from Logcat and I get this:intent
String:Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.android.providers.downloads.ui cmp=com.android.providers.downloads.ui/.DownloadsListTab }Intent
inside startActivity: Intent { act=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.android.providers.downloads.ui cmp=com.android.providers.downloads.ui/.DownloadsListTab } }
(My app crashed because of this wrong Intent)
As you can see, the String I passed back to the starting Activity is the Intent I need itself(in String)
So is there anyway I can make that String an Intent without Intent's Constructor? Or maybe a way to pass Intent directly to the starting Activity?