Open another app within a fragment

﹥>﹥吖頭↗ 提交于 2019-12-13 07:26:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!