Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何读取Adb Dumpsys报警输出_Android_Cmd_Adb_Alarmmanager_Dumpsys - Fatal编程技术网

Android 如何读取Adb Dumpsys报警输出

Android 如何读取Adb Dumpsys报警输出,android,cmd,adb,alarmmanager,dumpsys,Android,Cmd,Adb,Alarmmanager,Dumpsys,我通过alarm manager在repeat上设置了多个报警,它们在设置当天工作正常,但根本不重复。我已经更新了我的代码,但我不能整天等待检查代码是否正常工作,因此我尝试了adb shell dumpsys alarm命令,但我不知道如何正确读取输出以及如何提取设置的报警时间。我通过一些链接了解了输出,但没有一个链接具体说明如何检查设置的报警的准确时间。 这是我的输出 我设置闹钟的主代码 final int _id = (int) System.currentTimeMillis();

我通过alarm manager在repeat上设置了多个报警,它们在设置当天工作正常,但根本不重复。我已经更新了我的代码,但我不能整天等待检查代码是否正常工作,因此我尝试了adb shell dumpsys 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”命令的开源项目。你可以在这里找到它:


希望它能帮助您找出错误所在

发布您的代码,了解如何设置alarm@OBX就这么做了。检查