安卓開發跳轉其他app指定activity

聲明:

                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");

//              不要設置Categoryaction,否則會跳轉到主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);



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章