问题
I am creating an app to run multiple tasks within a same activity. I am achieving this using fragments. Now, I want to run a game which is installed on my phone in a fragment within my activity.
I tried this :
PackageManager pm = getActivity().getPackageManager();
Intent intent = pm.getLaunchIntentForPackage("com.exo.drive");
getActivity().startActivityFromFragment(this, intent, getTargetRequestCode());
But this as expected opens another activity and launches the game. How do I make the game run within my fragment?
回答1:
You can't. You can only add or replace the contents of a fragment container with a fragment, and even then, you can't take another installed app's fragment and add it to your view.
来源:https://stackoverflow.com/questions/25373862/open-another-app-within-a-fragment