一个片段中打开另一个应用程序 [英] Open another app within a fragment
本文介绍了一个片段中打开另一个应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建一个应用程序到同一个活动中运行多个任务。我实现这一目标用片段。现在,我要运行它安装在我的手机在我的活动中片段的游戏。
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.
我试过这样:
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?
推荐答案
您不能。只能添加或片段替换片段容器的内容,即使如此,你不能采取另一种安装的应用程序的片段,并将其添加到您的视图。
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.
这篇关于一个片段中打开另一个应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文