androidActivity和Service之間傳參數(shù)

在 Activity中

創(chuàng)新互聯(lián)建站-專(zhuān)業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性?xún)r(jià)比陽(yáng)江網(wǎng)站開(kāi)發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫(kù),直接使用。一站式陽(yáng)江網(wǎng)站制作公司更省心,省錢(qián),快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋陽(yáng)江地區(qū)。費(fèi)用合理售后完善,10余年實(shí)體公司更值得信賴(lài)。

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;

}

這里需要說(shuō)明的是 需要在onStartCommand()方法中接收數(shù)據(jù)

我原來(lái)在onCreate中接收 出現(xiàn)了 NullPoint 異常


新聞標(biāo)題:androidActivity和Service之間傳參數(shù)
URL鏈接:http://muchs.cn/article44/pdhsee.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT搜索引擎優(yōu)化、微信公眾號(hào)、商城網(wǎng)站、服務(wù)器托管、云服務(wù)器

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)