1.首先在当前应用的按钮的点击事件里面添加如下按钮
```
Intent intent = new Intent();
ComponentName cn = new ComponentName("open_open.com.androidagreedemo", "open_open.com.androidagreedemo.MainActivity");
try {
intent.setComponent(cn);
intent.putExtra("test", "intent1");
startActivity(intent);
} catch (Exception e) {
Log.i("charge app", "没有找到对应app");
}
```
2.接着需要将目标Activity的android:exported="true"属性在所属应用AndroidMainfest里设置为true(意思是当前Activity可以被外部应用访问)。
3.在当前应用的AndroidMainfest里声明目标Activity
```
<activity android:name="com.example.fm.MainFragmentActivity"></activity>
```
注意!(5.0以后不会报这个错)
就是这么简单!!!
>希望可以帮助大家
如果哪里有什么不对或者不足的地方,还望读者多多提意见或建议
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有