如何阅读Adb Dumpsys警报输出

时间:2017-01-30 17:46:46

标签: android cmd adb alarmmanager dumpsys

我通过闹钟管理器重复设置多个闹钟,它们在设置当天正常工作但根本不重复。我已经更新了我的代码,但是我不能整天等待检查代码是否正常工作,所以我尝试了adb shell dumpsys alarm命令,但我不知道如何正确读取输出以及如何提取正在设置的警报的次数。我已经按照一些链接来理解输出,但没有一个指定如何检查警报设置的确切时间。 这是我的输出 enter image description here

我的主要代码我在哪里设置闹钟

 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
       } 

1 个答案:

答案 0 :(得分:0)

也许它可以帮助你,我已经创建了一个开源项目,其中包含了一个GUI版本的" adb shell dumpsys alarm"命令。你可以在这里找到它:

https://github.com/Dottorhouse/DumpsysAlarm

希望它能帮助你找出错误的错误