2017-01-30 14 views
1

Я устанавливаю несколько аварийных сигналов на повтор через диспетчер аварийных сообщений, они работают нормально в тот день, когда они были установлены, но не повторяются вообще. Я обновил свой код, но я не могу ждать весь день, чтобы проверить, работает ли код даже, или нет, поэтому я пробовал команду аварийной команды adb shell dumpsys, но я не знаю, как правильно прочитать вывод и как извлечь время установленных аварийных сигналов. Я следил за некоторыми ссылками, чтобы понять выход, но ни один из них не указывает, как проверить точное время установки тревоги. вот мой выход enter image description hereКак читать выходной сигнал Adb Dumpsys

мой основной код, где я буду установки будильника

final int _id = (int) System.currentTimeMillis(); 

     AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); 

    // alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,AllTime[i],AlarmManager.INTERVAL_DAY, 
     //  PendingIntent.getBroadcast(this, _id, alertIntent, PendingIntent.FLAG_UPDATE_CURRENT)); 
     alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP,AllTime[i],AlarmManager.INTERVAL_DAY, 
       PendingIntent.getBroadcast(this, _id, alertIntent, PendingIntent.FLAG_UPDATE_CURRENT)); 

и это это приемник вещания

public void onReceive(Context context, Intent intent) { 


    String[] myStrings = intent.getStringArrayExtra("strings"); 
    Log.i("okk", "cathing intent values through break" + Arrays.toString(myStrings)); 


    createNotification(context, "Time is here baby", "this is the notification text", "Alert"); 
    Log.i("okk", "cathing intent values through break" + Arrays.toString(myStrings)); 


} 

public void createNotification(Context context, String msg, String msgText, String msgAlert) { 
    final int _id = (int) System.currentTimeMillis(); // unique request code 

    // will open mainActivity on notification click, can change it 
// PendingIntent notificationIntent = PendingIntent.getActivity(context, _id, new Intent(context, MainActivity.class), 0); // changed from 0 to _id 

    PendingIntent notificationIntent = PendingIntent.getActivity(context,0, new Intent(context,MainActivity.class),0); 
    NotificationCompat.Builder mbuilder = new NotificationCompat.Builder(context) 
      .setSmallIcon(R.drawable.cast_ic_notification_play) 
      .setContentTitle(msg) 
      .setTicker(msgAlert) 
      .setContentText(msgText); 

    // now intent we want to fire when noti is clicked 

    mbuilder.setContentIntent(notificationIntent); 

    // how person is notified 

    mbuilder.setDefaults(NotificationCompat.DEFAULT_SOUND); 

    mbuilder.setAutoCancel(true); // noti dismisble when user swipe it away 

    NotificationManager notificationManager = (NotificationManager) 
      context.getSystemService((Context.NOTIFICATION_SERVICE)); 

    // Log.i("okk", "NOTIFIED " + intent.getExtras()); 

    notificationManager.notify(1, mbuilder.build()); // changes from 1 to _id 
     } 
+0

разместить свой код, чтобы узнать, как вы настраиваете сигнал – OBX

+0

@OBX только что сделал. проверить –

ответ

0

может быть, это может помочь вам, Я создал проект с открытым исходным кодом с графической версией команды «команда adb shell dumpsys alarms». Вы можете найти его здесь:

https://github.com/Dottorhouse/DumpsysAlarm

Надеюсь, это поможет вам понять, что случилось