第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Broadcast service 沒有被調(diào)用

Broadcast service 沒有被調(diào)用

肥皂起泡泡 2019-03-20 18:15:33
我使用下面的代碼調(diào)用 Broadcast serviceIntent i = new Intent(this, BootUpReceiverRecall.class);         sendBroadcast(i);  <receiver  android:process=":remote" android:name="BootUpReceiverRecall"></receiver> public class BootUpReceiverRecall extends BroadcastReceiver  {       // Restart service every 30 seconds       private static final long REPEAT_TIME = 1000 * 30;       @Override       public void onReceive(Context context, Intent intent)        {         AlarmManager service = (AlarmManager) context             .getSystemService(Context.ALARM_SERVICE);         Intent i = new Intent(context, BootUpReceiver.class);         PendingIntent pending = PendingIntent.getBroadcast(context, 0, i,             PendingIntent.FLAG_CANCEL_CURRENT);         Calendar cal = Calendar.getInstance();         // Start 30 seconds after boot completed         cal.add(Calendar.SECOND, 30);         //         // Fetch every 30 seconds         // InexactRepeating allows Android to optimize the energy consumption         service.setInexactRepeating(AlarmManager.RTC_WAKEUP,             cal.getTimeInMillis(), REPEAT_TIME, pending);         // service.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),         // REPEAT_TIME, pending);       }但是我的BootUpReceiver 從來沒有被調(diào)用,哪里出錯(cuò)了呢?
查看完整描述

1 回答

?
holdtom

TA貢獻(xiàn)1805條經(jīng)驗(yàn) 獲得超10個(gè)贊

Intent i = new Intent(this, BootUpReceiverRecall.class);
        sendBroadcast(i);

為什么要這樣寫呢? 我是沒這樣寫過
廣播分2中注冊(cè)方式:
1中是代碼注冊(cè),局部廣播 可以寫在Activity中

YourReceiver reveiver = new YourReceiver ();
IntentFilter filter = new IntentFilter();
        filter.addAction("yourAction");
        registerReceiver(reveiver , filter);

Activity生命周期中可以管理register 和 unregister
2.manifest配置 節(jié)點(diǎn)下 
創(chuàng)建 YourReceiver在xx.xx.xx.receiver(隨便寫)包下 extends BrocastReceiver
根據(jù)action過濾

你這個(gè)可改成

Intent i = new Intent(“action”);
        sendBroadcast(i);


查看完整回答
反對(duì) 回復(fù) 2019-04-29
  • 1 回答
  • 0 關(guān)注
  • 437 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)