没有的onReceive触发

没有的onReceive触发

本文介绍了利用广播接收器捕捉来电,没有的onReceive触发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现一个简单的广播接收器,当有来电时它就会被触发。然而,似乎是的onReceive触发从来没有(我非常仔细地检查了LogCat中,没有输出那里),什么是错的? TKS
我的类:

 公共类MyPhoneReceiver扩展广播接收器{
    私有静态最后弦乐TAG =DEBUG    @覆盖
    公共无效的onReceive(上下文的背景下,意图意图){
        Log.e(TAG,测试loggiiiiiiiiiiiiiiiiiiiiiiiiing!);    }}

我的清单文件:

 <?XML版本=1.0编码=UTF-8&GT?;
    <清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    包=tung.le.android.receiver.phone
    安卓版code =1
    机器人:=的versionName1.0>
    <应用
        机器人:图标=@绘制/ ic_launcher
        机器人:标签=@字符串/ APP_NAME>
         <接收机器人:MyPhoneReceiverNAME =>
            &所述;意图滤光器>
                <作用机器人:名字=android.intent.action.PHONE_STATE>
                < /作用>            &所述; /意图滤光器>
        < /接收器>    < /用途>
    <采用-SDK安卓的minSdkVersion =15/>
    <使用许可权的android:NAME =android.permission.READ_PHONE_STATE>
    < /使用许可权>< /清单>


解决方案

可能这个教程可以解决你的问题

I want to implement a simple BroadcastReceiver, it gets triggered when there's an incoming call. However, it seems onReceive is never triggered (I checked the LogCat very carefully, no output there), what was wrong? TksMy class:

public class MyPhoneReceiver extends BroadcastReceiver {
    private static final String TAG = "DEBUG";

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.e(TAG, "Test loggiiiiiiiiiiiiiiiiiiiiiiiiing!");

    }

}

My manifest file:

<?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="tung.le.android.receiver.phone"
    android:versionCode="1"
    android:versionName="1.0" >


    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
         <receiver android:name=".MyPhoneReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.PHONE_STATE" >
                </action>

            </intent-filter>
        </receiver>

    </application>
    <uses-sdk android:minSdkVersion="15" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" >
    </uses-permission>

</manifest>
解决方案

may this tutorial can solve your problemhttp://www.tutorialforandroid.com/2009/01/get-phone-state-when-someone-is-calling_22.html

这篇关于利用广播接收器捕捉来电,没有的onReceive触发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 01:53