1.问题
在测试Android开启广播接受的时候,Android3.0之后就增加了权限,在模拟器测试的时候是可以接受到广播并且开启的指定的App。不过在真机上面调试的时候,一直不能接受到,开机广播不能接受,网上也看了很多文章,没有解决。
2.解决
我的手机是Android4.0的,真机调试时也按网上解决方法试了,增加权限,安装之后先运行了一次,设置自启动项。不过都没有用。原来是我安装App都是安装在SDCard上面的,刚开机时要加载SDCard,可能加载完之后App就无法就收到开机广播了,最后我把App移至系统空间才解决
public class BootReceiver extends BroadcastReceiver { private static final String TAG = "BootReceiver"; @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub Log.i(TAG, "广播已经接受"); Intent activityIntent = new Intent(context, MainActivity.class); activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(activityIntent); } }
<!-- 权限是3.0之后要添加的 --> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="15" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <receiver android:name="com.pt.receiver.BootReceiver"> <intent-filter > <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> </application>
相关推荐
android4.0测试代码;android4.0测试代码;android4.0测试代码;android4.0测试代码
Android4.0源码编译方法介绍,记录基于Ubuntu10.04编译Android4.0源码的过程。
android 4.0 sources 源码。主要用于编写程序时查看代码,即ctrl+鼠标单击
《细说Android 4.0 NDK编程》
Android 4.0 组件库 for Axure 模板 一个中文模板,一个详细组件,组合使用,相得益彰
android4.0 电子支付源码 NFC
android4.0 日历源码Calendar
mtk6577 android4.0 root工具
android4.0的原生照相机源代码,原生camera代码。
《细说Android4.0NDK编程》由王家林所著,通过NDK,应用程序可以非常方便地实现Java与C/C++代码的相互沟通。本书顺应Android软/硬件、云计算整合潮流,详细剖析了NDK开发中涉及的各类问题和解决方案:搭建Android ...
android4.0_Browser
android4.0-api14 无需解释
压缩包内是原生的android4.0图库代码
之前上传的(http://download.csdn.net/detail/michael__li/3797623)有网友反应有部分API没有包含,这次是修复好了,包含所有的API,最完整的Android4.0 API 源代码。 下载的压缩包里有使用方法,下载后在Eclipse里...
压缩包内是android4.0的电话模块源代码
Android 系统4.0 命名为 Ice Cream Sandwich(简称ICS,冰淇淋三明治),是谷歌发布新一代操作系统。Android4.0 拥有十大重点新特性。集成谷歌电视和Chrome OS的智能停放 ,运行速度得到进一步提升。2011年10月19日...
Android 4.0 Camera源码,该代码为Andriod 4.0 系统相机源代码。
《Android 4.0网络编程详解》对Android 4.0网络编程中的XML形式,JSON操作,需要掌握的HTTP知识,数据下载上传,Socket编程,浏览器开发,Android中软件界面设计新大陆——采用HTML设计软件界面,Android应用程序的...
本文将指导你如何在电脑上安装模拟器体验Android 4.0
tools_r14-linux.zip android 4.0 sdk tools