課程
/移動開發
/Android
/AIDL-小白成長記
空指針,明顯沒有綁定成功,綁定回調都沒有走,不知道什么鬼。
而且我都搞不懂要不要在清單文件配置service
2017-12-18
源自:AIDL-小白成長記 2-2
正在回答
不用啟動服務吧?
首先服務端清單文件中配置Service
? ? ?<!-- 使用 android:exported="true" 屬性將當前 Service 暴露出去,
? ? ? ?使其它進程的組件也能與綁定當前 Service -->
? ? ? ?<service android:name=".IRemoteService" android:exported="true"/>
2.其次在服務端中啟動這個Service,代碼如下:
public class MainActivity extends AppCompatActivity {
? ?@Override
? ?protected void onCreate(Bundle savedInstanceState) {
? ? ? ?super.onCreate(savedInstanceState);
? ? ? ?setContentView(R.layout.activity_main);
? ? ? ?Intent intent = new Intent(this, IRemoteService.class);
? ? ? ?startService(intent);
? ?}
}
舉報
AIDL-小白成長記,想要快速入門,看本次的教程就對了
2 回答java.lang.NullPointerException: Attempt to invoke interface method 'int cn.sdut.zhouprj.IMyAidlInterface.sum(int, int)' on a null object reference
4 回答空指針異常
1 回答空指針異常
2 回答空指針異常?。?!
2 回答空指針異常
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2020-03-10
不用啟動服務吧?
2017-12-22
首先服務端清單文件中配置Service
? ? ?<!-- 使用 android:exported="true" 屬性將當前 Service 暴露出去,
? ? ? ?使其它進程的組件也能與綁定當前 Service -->
? ? ? ?<service android:name=".IRemoteService" android:exported="true"/>
2.其次在服務端中啟動這個Service,代碼如下:
public class MainActivity extends AppCompatActivity {
? ?@Override
? ?protected void onCreate(Bundle savedInstanceState) {
? ? ? ?super.onCreate(savedInstanceState);
? ? ? ?setContentView(R.layout.activity_main);
? ? ? ?Intent intent = new Intent(this, IRemoteService.class);
? ? ? ?startService(intent);
? ?}
}