android– 在收听Deskclock报警意图时,Logcat无法在广播接收器中的onReceive内工作

android– 在收听Deskclock报警意图时,Logcat无法在广播接收器中的onReceive内工作,第1张

概述我正在使用我的广播接收收听deskclock警报更改意图.当调用我的广播接收器中的onReceive()方法时,onReceive中的日志(Log.i/v())不会在Android监视器上打印,但Toasts正常工作.清单文件:<?xmlversion="1.0"encoding="utf-8"?><manifestxmlns:android="http://schemas.andro @H_419_0@我正在使用我的广播接收器收听deskclock警报更改意图.当调用我的广播接收器中的onReceive()方法时,onReceive中的日志(Log.i / v())不会在Android监视器上打印,但Toasts正常工作.

@H_419_0@清单文件:

@H_419_0@

<?xml version="1.0" enCoding="utf-8"?><manifest xmlns:androID="http://schemas.androID.com/apk/res/androID"     package="com.dumbrella.ratemyday"><uses-permission androID:name="com.androID.alarm.permission.SET_ALARM"/><application    androID:allowBackup="true"    androID:icon="@mipmap/ic_launcher"    androID:label="@string/app_name"    androID:supportsRtl="true"    androID:theme="@style/Apptheme">    <activity androID:name=".MainActivity">        <intent-filter>            <action androID:name="androID.intent.action.MAIN" />            <category androID:name="androID.intent.category.LAUNCHER" />        </intent-filter>    </activity>    <receiver androID:process=":remote" androID:name="AlarmClockReceiver">        <intent-filter>            <action androID:name="com.androID.deskclock.ALARM_disMISS" />            <action androID:name="com.androID.deskclock.ALARM_SNOOZE" />            <action androID:name="com.androID.deskclock.ALARM_ALERT" />            <action androID:name="com.androID.deskclock.ALARM_DONE" />        </intent-filter>    </receiver></application></manifest>
@H_419_0@广播接收器:

@H_419_0@

import androID.content.broadcastReceiver;import androID.content.Context;import androID.content.Intent;import androID.util.Log;import androID.Widget.Toast;import java.text.SimpleDateFormat;public class AlarmClockReceiver extends broadcastReceiver {    @OverrIDe    public voID onReceive(Context context, Intent intent) {        // This log.v does not get printed on AndroID Monitor        Log.v("broadcast Test", "In broadcast Listener");        String message = "broadcast intent detected "            + intent.getAction();        // This toast gets displayed after the alarm is dismissed          Toast.makeText(context, message,Toast.LENGTH_LONG).show();    }} 

解决方法:

@H_419_0@也许这已经太晚了,但是我把它留给了这个问题的未来程序员,我遇到了类似的问题并以这种方式解决了.
只需在Logcat面板中,将过滤列表框更改为“无过滤器”.

总结

以上是内存溢出为你收集整理的android – 在收听Deskclock报警意图时,Logcat无法在广播接收器中的onReceive内工作全部内容,希望文章能够帮你解决android – 在收听Deskclock报警意图时,Logcat无法在广播接收器中的onReceive内工作所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1119434.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存