日報2015/10/20(極客學院安卓視頻學習)

Android 中 AIDL 的理解與使用

我們知道,可以通過隱式Intent來跨應用啓動Activity,通過配置
intent-filter中的Action:

startActivity(new Intent("aty_B"));

對於跨應用啓動Service的情況,Android 5.0之後就不允許通過隱式啓動了。

serviceIntent = new Intent();
serviceIntent.setComponent(new     ComponentName("com.jackie.startanotherapp", "com.jackie.startanotherapp.AppService"));
startService(serviceIntent);

這裏指定了包名,類名,因此是一個顯式啓動,合符要求。
啓動/停止anotherApp中的按鈕,主意Logcat要切換到包含Service的那個app,

10-20 22:17:46.231 26358-26358/com.jackie.startanotherapp V/jackie: Service created
10-20 22:17:50.376 26358-26358/com.jackie.startanotherapp V/jackie: Service destroyed
發佈了30 篇原創文章 · 獲贊 0 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章