Android Intents: Start activity using class name from another app that has the same sharedUserId

南笙酒味 提交于 2020-01-02 00:47:09

问题


All my apps have the same sharedUserId. I would like to start a class of another app using the class of my current app. I want to use intent extras but I do not want to use intent URLs. I also would prefer not to have to change the AndroidManifest of my target activity's app.


回答1:


Its pretty easy since you have the sharedUserId set.

Intent res = new Intent();
String mPackage = "com.your.package";
String mClass = ".actYouAreLaunching";
res.setComponent(new ComponentName(mPackage,mPackage+mClass));
startActivity(res);

And that's all there is to it. You can add intent extras like you normally would.



来源:https://stackoverflow.com/questions/4770847/android-intents-start-activity-using-class-name-from-another-app-that-has-the-s

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