Android 4以上的系统,APP如何获得开机播放?
问题描述:
我想做些什么,当我得到BOOT_COMPLETED,但现在,我的应用程序无法获得BOOT_COMPLETED.And我的手机是Android的4.0系统。 谢谢!Android 4以上的系统,APP如何获得开机播放?
答
清单
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
// if u want to start service
// <service android:name="com.example.afterbootservice.MyService" > </service>
<receiver android:name="YOUR PACKAGE NAME.BooteRecevier" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
创建BooteRecevier
public class BooteRecevier extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Intent service = new Intent(context,MyService.class);
context.startService(service);
// do what u want after boot in above to line i starting service when boot comple
}
}
你会请发表您的代码在这里 –
什么是你的目标API @先生。 Feng.We可以回答你是否提供了有关你的问题的正确信息。请发布你的完整代码。 – Lampard