在 Activity中
創(chuàng)新互聯(lián)建站-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比陽江網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式陽江網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋陽江地區(qū)。費(fèi)用合理售后完善,10余年實(shí)體公司更值得信賴。
Intent intent = new Intent();
intent.setAction("jingbao_Service");
intent.putExtra("flag", true);
startService(intent);
在Service中
public int onStartCommand(Intent intent, int flags, int startID){
Log.v(null, "onStartCommand");
//intent = new Intent();
Bundle bundle = intent.getExtras();
boolean flag = bundle.getBoolean("flag");
if(flag == true){
musicStart();
}else{
musicStop();
}
return START_STICKY;
}
這里需要說明的是 需要在onStartCommand()方法中接收數(shù)據(jù)
我原來在onCreate中接收 出現(xiàn)了 NullPoint 異常
新聞標(biāo)題:androidActivity和Service之間傳參數(shù)
URL鏈接:http://aaarwkj.com/article44/pdhsee.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT、搜索引擎優(yōu)化、微信公眾號、商城網(wǎng)站、服務(wù)器托管、云服務(wù)器
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)