如何读取Adb Dumpsys警报输出 [英] How to read Adb Dumpsys alarm output

查看:196
本文介绍了如何读取Adb Dumpsys警报输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过警报管理器将多个警报设置为重复,它们在设置当天就可以正常工作,但根本没有重复。我已经更新了代码,但是等不及要整天检查代码是否正常工作,因此我尝试了adb shell dumpsys alarm命令,但是我不知道如何正确读取输出以及如何提取时间设置的警报。我已经跟踪了一些链接以了解输出,但是都没有指定如何检查设置警报的确切时间。
这是我的输出

I'm setting multiple alarms on repeat through alarm manager, they are working fine on the day they got set but not repeating at all. I have updated my code but I can't wait all day to check if the code is even working or not so I have tried adb shell dumpsys alarm command but I don't know how to read the output properly and how to extract the times of alarms being set. I have followed some links to understand the output but none is specifiying how to check the exact time of the alarm being set. here is my output

我在其中设置警报的主代码

my main code where i'm setting the alarm

 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
       } 


推荐答案

也许它可以为您提供帮助,我已经使用GUI版本的 adb shell dumpsys alarms命令创建了一个开源项目。您可以在这里找到它:

maybe it can help you, I've created an opensource project with a GUI version of the "adb shell dumpsys alarms" command. You can find it here:

https:// github .com / Dottorhouse / DumpsysAlarm

希望它能帮助您找出问题所在

Hopefully it will help you figure out what's wrong

这篇关于如何读取Adb Dumpsys警报输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆