課程
/移動(dòng)開發(fā)
/Android
/AIDL-小白成長記
空指針,明顯沒有綁定成功,綁定回調(diào)都沒有走,不知道什么鬼。
而且我都搞不懂要不要在清單文件配置service
2017-12-18
源自:AIDL-小白成長記 2-2
正在回答
不用啟動(dòng)服務(wù)吧?
首先服務(wù)端清單文件中配置Service
? ? ?<!-- 使用 android:exported="true" 屬性將當(dāng)前 Service 暴露出去,
? ? ? ?使其它進(jìn)程的組件也能與綁定當(dāng)前 Service -->
? ? ? ?<service android:name=".IRemoteService" android:exported="true"/>
2.其次在服務(wù)端中啟動(dòng)這個(gè)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);
? ?}
}
舉報(bào)
AIDL-小白成長記,想要快速入門,看本次的教程就對(duì)了
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 回答空指針異常!?。?/p>
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2020-03-10
不用啟動(dòng)服務(wù)吧?
2017-12-22
首先服務(wù)端清單文件中配置Service
? ? ?<!-- 使用 android:exported="true" 屬性將當(dāng)前 Service 暴露出去,
? ? ? ?使其它進(jìn)程的組件也能與綁定當(dāng)前 Service -->
? ? ? ?<service android:name=".IRemoteService" android:exported="true"/>
2.其次在服務(wù)端中啟動(dòng)這個(gè)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);
? ?}
}