android 打开另外一个apk并且传值过去

//...... 设置要启动应用程序的包名 与 要启动的Activity
ComponentName apk2Component = new ComponentName("com.houzhenyu.apk2", "com.houzhenyu.apk2.MainActivity");
//................................................... 创建意图与参数对象
Intent intent = new Intent();
Bundle bundle = new Bundle();
//................................................... 传递给apk2的参数
bundle.putString("userName", "houzhenyu");
bundle.putString("userMail", "[email protected]");
//................................................... 将参数对象与apk2组件设置给意图
intent.putExtras(bundle);
intent.setComponent(apk2Component);
//................................................... 启动意图,将会打开apk2
startActivity(intent);

猜你喜欢

转载自iaiai.iteye.com/blog/1744953
今日推荐