[問題] AIDL永遠不會connect

作者: winsummer (winsummer)   2017-07-21 15:01:21
各位前輩好
我的程式ServiceConnection永遠不會被呼叫
不知道是那裏出了問題
Debug了2天..
貼上程式碼
http://ideone.com/46JLBU
另外
AndroidManifest.xml
也加上了
<service
android:name="com.topway.swiftplayservic.IPlayAIDLServicee"
android:process=":remote"
android:exported="true"
android:enabled="true">
<intent-filter>
<action android:name="SwiftPlayService"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</service>
不知道原因出在那邊
謝謝
作者: ssccg (23)   2017-07-21 15:09:00
你的intent幹麻setPackage? 傳的還是class不是package?另外你new Intent用到的是String action這個ctor簡單的說你現在這個寫法,會變成去找package name為com.topway.swiftplayservice.IPlayAIDLService的App中manifest裡有個intent filter的action叫做com.topway.swiftplayservice.IPlayAIDLService的service但是你manifest裡action是SwiftPlayService至於package name是什麼你沒寫,不過我想不會是class name你不加或是改成別的當然也沒用,因為沒有符合的action你是要呼叫別的App中的service?manifest不用寫,Intent要看對方的manifest怎麼寫的
作者: winsummer (winsummer)   2017-07-21 17:05:00
那getPackage也不用寫嗎
作者: ssccg (23)   2017-07-21 17:26:00
setPackage是限定找特定的app,通常是像Intent.ACTION_VIEW這種會找到一堆的Intent時選特定app用如果有正確的ComponentName(package name + class name)其他都不需要,如果是用action,像這種service通常也不太會重複也不需要
作者: winsummer (winsummer)   2017-07-24 11:04:00
了解 謝謝解答
作者: KeySabre (KeySabreur)   2017-08-04 02:17:00
intent 該是 implicit 或 explicit 的問題

Links booklink

Contact Us: admin [ a t ] ucptt.com