引导接收器不工作 [英] Boot Receiver not working

查看:319
本文介绍了引导接收器不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

清单:

         <application android:icon="@drawable/icon" android:label="@string/app_name">
            <activity android:name=".AlarmActivity"
                      android:label="@string/app_name">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                </intent-filter>
            </activity>
            <receiver android:name="CallReciver">
                <intent-filter>
                    <action android:name="android.intent.action.PHONE_STATE">  

</action>
                </intent-filter>
            </receiver>
            <receiver android:name=".SmsReceiver"> 
               <intent-filter android:priority="1000">
                    <action android:name=
                        "android.provider.Telephony.SMS_RECEIVED" /> 
                </intent-filter> 
            </receiver>
             <receiver android:name=".OnBootReceiver">
          <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
          </intent-filter>
        </receiver>
            <service
                android:enabled="true"
                android:name=".AlarmService">
            </service>
        </application>
         <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED">
         </uses-permission>
        <uses-permission android:name="android.permission.READ_PHONE_STATE">
        </uses-permission>
        <uses-permission android:name="android.permission.WRITE_SMS">
        </uses-permission>
       <uses-permission android:name="android.permission.READ_SMS">
        </uses-permission>
       <uses-permission android:name="android.permission.SEND_SMS">
        </uses-permission>
        <uses-permission android:name="android.permission.RECEIVE_SMS">
        </uses-permission>
        <uses-permission android:name="android.permission.INTERNET">
        </uses-permission>

接收器:

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

public class OnBootReceiver extends BroadcastReceiver
{
    @Override
    public void onReceive(Context context, Intent intent)
    {
        Log.d("Test","booot");
        Toast.makeText(context, "Test", Toast.LENGTH_LONG).show();
    }
}

接收器不工作。我关闭,我的设备上,没有任何反应。
短信和呼叫接收器在这个项目中工作良好。
短信接收器和CallReceviver - 做工不错。
更新后第一 - 添加了完整的清单。

Receiver doesn't work. I turn off and on my device and nothing happens. SMS And Call Receiver in this project work good. SMS Receiver and CallReceviver - works good. First post updated - added full manifest.

推荐答案

如果您有HTC设备还需要为android.intent.action.QUICKBOOT_POWERON注册。因此,在清单中的条目应该是:

If you have HTC device you also need to register for "android.intent.action.QUICKBOOT_POWERON". So the entry in manifest should be:

    <receiver android:name=".OnBootReceiver"> 
        <intent-filter> 
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.QUICKBOOT_POWERON" />
        </intent-filter> 
    </receiver>    

在我的HTC,如果我关闭设备并打开了一段时间我QUICKBOOT_POWERON没有BOOT_COMPLETED。

On my HTC, if I turn off the device and turn it on for a while I got QUICKBOOT_POWERON and no BOOT_COMPLETED.

如果我关掉设备并一会儿取出电池 - 我被启动后BOOT_COMPLETED

If I turn off the device and remove battery for a while - I got BOOT_COMPLETED after start.

这篇关于引导接收器不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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