试图在android上启动一个服务
<receiver android:name=".StartServiceAtBootReceiver" android:enabled="true" android:exported="false" android:label="StartServiceAtBootReceiver" > <intent-filter> <action android:name="android.intent.action._BOOT_COMPLETED" /> </intent-filter></receiver><service android:name="com.test.RunService" android:enabled="true" />
public void onReceive(Context context, Intent intent) {
if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
Intent serviceLauncher = new Intent(context, RunService.class);
context.startService(serviceLauncher);
Log.v("TEST", "Service loaded at start");
}}
慕沐林林
莫回无
呼唤远方
随时随地看视频慕课网APP