为什么receive_boot_completed没有我的设备上运行? [英] why receive_boot_completed doesn't work on my device?
问题描述
我是开发一些应用程序需要使用 receive_boot_completed
在重新启动重新设定报警
这是正常工作的模拟器和三星标签2 10.1 ..但它不工作对我的星系小型设备与Android版本2.2.1 !!!
这在我的code:
的manifest.xml
< XML版本=1.0编码=UTF-8&GT?;
<舱单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=com.engahmedphp.collector
机器人:INSTALLLOCATION =自动
安卓版code =1
机器人:VERSIONNAME =1.0>
<用途-SDK
安卓的minSdkVersion =8
机器人:targetSdkVersion =18/>
<使用-权限的Android:名称=android.permission.INTERNET对/>
<使用-权限的Android:名称=android.permission.ACCESS_NETWORK_STATE/>
<使用-权限的Android:名称=android.permission.WRITE_EXTERNAL_STORAGE/>
<使用-权限的Android:名称=android.permission.RECEIVE_BOOT_COMPLETED/>
<应用
机器人:allowBackup =真
机器人:图标=@可绘制/ app_icon
机器人:标签=@字符串/ APP_NAME
机器人:主题=@风格/ AppTheme>
<活动
机器人:名称=com.engahmedphp.collector.SplashActivity
机器人:标签=@字符串/ APP_NAME
机器人:主题=@安卓风格/ Theme.NoTitleBar.Fullscreen>
<意向滤光器>
<作用机器人:名称=android.intent.action.MAIN/>
<类机器人:名称=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT;
<活动
机器人:名称=。PagesActivity
机器人:标签=@字符串/ APP_NAME>
< /活性GT;
<活动
机器人:名称=。FeedsActivity
机器人:configChanges =方向| keyboardHidden
机器人:标签=@字符串/ APP_NAME>
< /活性GT;
<活动
机器人:名称=页面prefsActivity
机器人:标签=@字符串/ APP_NAME>
< /活性GT;
<活动
机器人:名称=。ManagePagesActivity
机器人:launchMode =singleTask
机器人:标签=@字符串/ APP_NAME>
< /活性GT;
<活动
机器人:名称=。FeedsDialogActivity
机器人:configChanges =方向| keyboardHidden
机器人:主题=@安卓风格/ Theme.Dialog
>
< /活性GT;
<接收机器人:FeedsReceiverNAME =>
< /接收器>
<接收机器人:名称=。BootCompletedReceiver
机器人:启用=真
机器人:权限=android.permission.RECEIVE_BOOT_COMPLETED>
<意向滤光器>
<作用机器人:名称=android.intent.action.BOOT_COMPLETED/>
<类机器人:名称=android.intent.category.DEFAULT/>
&所述; /意图滤光器>
< /接收器>
<服务机器人:名称=。GetFeedsService>
< /服务>
<服务机器人:名称=。ResetAlarmsService>
< /服务>
< /用途>
< /舱单>
BootCompletedReceiver.java
包com.engahmedphp.facebookcollector;
进口android.content.BroadcastReceiver;
进口android.content.Context;
进口android.content.Intent;
进口android.util.Log;
进口android.widget.Toast;
公共类BootCompletedReceiver扩展的BroadcastReceiver {
// ================================================ ==============================
@覆盖
公共无效的onReceive(上下文的背景下,意图意图){
Toast.makeText(背景下,好,Toast.LENGTH_LONG).show();
Log.e(启动,启动);
意图resetAlarms =新的意图(背景下,ResetAlarmsService.class);
context.startService(resetAlarms);
}
}
尝试把此行接收机的意图过滤器。
<作用机器人:名称=android.intent.action.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE/>
如果您的应用程序安装在SD卡上,您应该注册此得到android.intent.action.BOOT_COMPLETED事件。
更新时间: 由于您的应用程序使用的报警服务,它不应该被安装在外部存储。 参考: http://developer.android.com/guide/topics/data /install-location.html
i am developing some app need to use receive_boot_completed
on rebooting to reset some alarms
it 's working properly on emulator and Samsung tab 2 10.1 .. but it isn't working on my galaxy mini device with android version 2.2.1 !!!
this in my code :
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.engahmedphp.collector"
android:installLocation="auto"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.engahmedphp.collector.SplashActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".PagesActivity"
android:label="@string/app_name" >
</activity>
<activity
android:name=".FeedsActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/app_name" >
</activity>
<activity
android:name=".PagePrefsActivity"
android:label="@string/app_name" >
</activity>
<activity
android:name=".ManagePagesActivity"
android:launchMode="singleTask"
android:label="@string/app_name" >
</activity>
<activity
android:name=".FeedsDialogActivity"
android:configChanges="orientation|keyboardHidden"
android:theme="@android:style/Theme.Dialog"
>
</activity>
<receiver android:name=".FeedsReceiver" >
</receiver>
<receiver android:name=".BootCompletedReceiver"
android:enabled="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</receiver>
<service android:name=".GetFeedsService" >
</service>
<service android:name=".ResetAlarmsService" >
</service>
</application>
</manifest>
BootCompletedReceiver.java
package com.engahmedphp.facebookcollector;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;
public class BootCompletedReceiver extends BroadcastReceiver {
// ==============================================================================
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "nice", Toast.LENGTH_LONG).show();
Log.e("boot", "boot");
Intent resetAlarms = new Intent(context, ResetAlarmsService.class);
context.startService(resetAlarms);
}
}
try to put this line in your receiver's intent-filter.
<action android:name="android.intent.action.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE" />
If your application is installed on the SD card, you should register this to get the android.intent.action.BOOT_COMPLETED event.
Updated: Since your app is using alarm service, it should not be installed on external storage. Reference: http://developer.android.com/guide/topics/data/install-location.html
这篇关于为什么receive_boot_completed没有我的设备上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!