我的BroadcastReceiver没有收到我的N1启动后BOOT_COMPLETED意图。请帮助! [英] My BroadcastReceiver is not receiving the BOOT_COMPLETED intent after my N1 boots. Help Please!

查看:130
本文介绍了我的BroadcastReceiver没有收到我的N1启动后BOOT_COMPLETED意图。请帮助!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法得到我的BroadcastReceiver的onReceive方法使用BOOT_COMPLETED意图调用。

AndroidManifest.xml中

 < XML版本=1.0编码=UTF-8&GT?;
<舱单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
      包=com.jerrellmardis.umbrella
      安卓版code =4
      机器人:VERSIONNAME =1.0.3>
    <应用机器人:图标=@可绘制/图标机器人:标签=@字符串/ APP_NAME
            机器人:主题=@安卓风格/ Theme.NoTitleBar>
        <活动机器人:activities.Umbrella名称=机器人:screenOrientation =画像>
            <意向滤光器>
                <作用机器人:名称=android.intent.action.MAIN/>
                <类机器人:名称=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;
        <活动机器人。活动preferencesNAME =机器人:标签=@字符串/ APP_NAME机器人:screenOrientation =画像/>
        <接收器的Andr​​oid版本:NAME =com.jerrellmardis.umbrella.receiver.WeatherStartu preceiver>
            <意向滤光器>
                <作用机器人:名称=android.intent.action.BOOT_COMPLETED/>
            &所述; /意图滤光器>
        < /接收器>
        <服务机器人。service.WeatherUpdateServiceNAME =>
            <意向滤光器>
                <作用机器人:名称=com.jerrellmardis.umbrella.service.WeatherUpdateService/>
            &所述; /意图滤光器>
        < /服务>
    < /用途>
    <使用-SDK安卓的minSdkVersion =3/>
    <使用-权限的Andr​​oid:名称=android.permission.INTERNET对/>
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_NETWORK_STATE/>
    <使用-权限的Andr​​oid:名称=android.permission.READ_PHONE_STATE/>
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_COARSE_LOCATION/>
    <使用-权限的Andr​​oid:名称=android.permission.VIBRATE/>
    <使用-权限的Andr​​oid:名称=android.permission.RECEIVE_BOOT_COMPLETED/>
< /舱单>
 

WeatherStartu preceiver.java

 包com.jerrellmardis.umbrella.receiver;

进口android.app.Notification;
进口android.app.NotificationManager;
进口android.app.PendingIntent;
进口android.content.BroadcastReceiver;
进口android.content.Context;
进口android.content.Intent;
进口android.provider.Contacts.People;
进口android.util.Log;

进口com.jerrellmardis.umbrella.R;

公共类WeatherStartu preceiver延伸的BroadcastReceiver {

       私人NotificationManager mNotificationManager;
       私人诠释SIMPLE_NOTFICATION_ID;

       @覆盖
       公共无效的onReceive(上下文的背景下,意图意图){
                //做一些有趣的事情在这里...
       }
}
 

解决方案

所有接收的 BOOT_COMPLETED 广播的应用程序必须在内部存储安装,因为Android的提供 ACTION_BOOT_COMPLETED 播放外部存储设备安装到设备中。

要确保您的应用程序将在您只需要内存安装不会声明机器人:INSTALLLOCATION 的属性。

另一种选择是设置在清单中部分如下:机器人:INSTALLLOCATION =internalOnly

您可以找到更多有关它的信息这里

I am unable to get my BroadcastReceiver onReceive method called using the BOOT_COMPLETED intent.

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.jerrellmardis.umbrella"
      android:versionCode="4"
      android:versionName="1.0.3">
    <application android:icon="@drawable/icon" android:label="@string/app_name" 
            android:theme="@android:style/Theme.NoTitleBar">
        <activity android:name=".activities.Umbrella" android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".activities.Preferences" android:label="@string/app_name" android:screenOrientation="portrait" />
        <receiver android:name="com.jerrellmardis.umbrella.receiver.WeatherStartupReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>
        <service android:name=".service.WeatherUpdateService">
            <intent-filter>
                <action android:name="com.jerrellmardis.umbrella.service.WeatherUpdateService" />
            </intent-filter>
        </service>
    </application>
    <uses-sdk android:minSdkVersion="3" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
</manifest>

WeatherStartupReceiver.java

package com.jerrellmardis.umbrella.receiver;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.provider.Contacts.People;
import android.util.Log;

import com.jerrellmardis.umbrella.R;

public class WeatherStartupReceiver extends BroadcastReceiver {

       private NotificationManager mNotificationManager;
       private int SIMPLE_NOTFICATION_ID;

       @Override
       public void onReceive(Context context, Intent intent) {
                // Do something interesting here...
       }
}

解决方案

All the applications that receive the BOOT_COMPLETED broadcast must be installed on the internal storage because Android delivers ACTION_BOOT_COMPLETED broadcast before the external storage is mounted to the device.

To ensure that your application will be installed on the internal memory you just need NOT to declare the android:installLocation manifest attribute.

Another option is to set the following in the manifest section: android:installLocation="internalOnly"

You can find more information about it here.

这篇关于我的BroadcastReceiver没有收到我的N1启动后BOOT_COMPLETED意图。请帮助!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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