【问题标题】:How to read Adb Dumpsys alarm output [duplicate]如何读取 Adb Dumpsys 警报输出 [重复]
【发布时间】:2017-07-06 17:52:08
【问题描述】:

我正在通过警报管理器重复设置多个警报,它们在设置的那天工作正常,但根本不重复。我已经更新了我的代码,但我等不及要检查代码是否正常工作,所以我尝试了 adb shell 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
       } 

【问题讨论】:

  • 发布您的代码以了解您是如何设置闹钟的
  • @OBX 刚刚做了。检查

标签: android cmd adb alarmmanager dumpsys


【解决方案1】:

也许它可以帮助你,我已经创建了一个开源项目,它带有一个 GUI 版本的“adb shell dumpsys alarms”命令。你可以在这里找到它:

https://github.com/Dottorhouse/DumpsysAlarm

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-20
    • 2013-07-27
    • 1970-01-01
    相关资源
    最近更新 更多