安卓開發跳轉其他app指定activity
阿新 • • 發佈:2019-02-06
宣告:
0、原創,轉載請備註本文連結
1、所提供連結內容僅供參考,後果自負
2、真正的大師,永遠都懷著一顆學徒的心
技術點:
0、什麼是隱式Intent和顯示Intent http://www.2cto.com/kf/201301/183599.html
1、什麼是Acition和Category,有哪些值 http://blog.csdn.net/gf771115/article/details/7827833
2、setComponent、setAction、setClass、setClassName幹嘛的
程式碼:程式A的B介面要跳轉到程式C的D介面
在程式C中配置
<activity
android:name="C的包名.D"
android:exported="true">
<intent-filter>
<action android:name="jie.jing.test" />
<category android:name="jie.jing.t" />
</intent-filter>
</activity>
在程式A的B中配置
Intent intent = new Intent(); intent.setClassName("C的包名", "C的包名.D"); // 不要設定Category和action,否則會跳轉到主activity // intent.addCategory("jie.jing.t"); // int launchFlags = Intent.FLAG_ACTIVITY_NEW_TASK // | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED;// intent.setFlags(launchFlags); // intent.setAction("jie.jing.test"); Bundle bundle = new Bundle(); bundle.putString("from", "來自測試應用"); intent.putExtras(bundle); startActivity(intent);