最贊回答 / qq_sunshine_162
另外服務端要注冊服務,并且允許遠程,不然會發生安全性異常<service android:name=".MService" ? ? ? ? android:process=":remote" ? ? ? ? android:exported="true" ? ?/>
2018-02-28
最贊回答 / 高進335
首先服務端清單文件中配置Service? ? ?<!-- 使用 android:exported="true" 屬性將當前 Service 暴露出去,? ? ? ?使其它進程的組件也能與綁定當前 Service -->? ? ? ?<service android:name=".IRemoteService" android:exported="true"/>2.其次在服務端中啟動這個Service,代碼如下:public class MainActivity extends Ap...
2017-12-18
發現空指針的問題是因為服務端沒有啟動服務!?。≡诜斩思尤雜tartService(new Intent(this,xxxService.class)); xxxService就是你的 new 接口.Stub()的那個類?。?!
2017-12-03
程序運行后,點擊計算按鈕,會出現空指針異常,也就是在調用add方法的時候,首先看一下Service有沒有注冊,如果注冊了,就是Service類里返回IBinder的onBind方法return null了,只需要將下面IIMyAidlInterface.Stub()返回的iBinder,放在onBind方法 return iBinder就好了,親測有用。
2017-11-09
感覺變了好多,我使用的是Android sutdio 2.3.3,測試機5.1.1(真機),如果使用老師那個種方式,也就是setComponent,會拋出空指針異常。但是如果使用顯示Intent,也就是 Intent intent = new Intent(this, MyService.class),這種方式來調用的是正確。還有一個問題,老師只是bindService,沒有startService,其實后臺服務是沒有啟動的,我在真機測試了的(也有可能還有情況,希望甄別)。還有就是在服務端的AndroidManifest注冊服務,至于其他人說設置exported和process,我沒有設置也行
2017-09-24