启动接收机无法正常工作 [英] Boot Receiver not work

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

问题描述

清单:

         <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天全站免登陆