我的启动回收:
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import gd.rf.ddl.vipchild.service.BootService;
public class DeviceBootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent startServiceIntent = new Intent(context, BootService.class);
context.startService(startServiceIntent);
}
}
我的android_mainfiest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="gd.rf.ddl.vipchild">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".walkin">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="gd.rf.ddl.vipchild.Home"
android:label="@string/app_name" >
</activity>
<receiver android:name="gd.rf.ddl.vipchild.DeviceBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<service android:enabled="true"
android:name="gd.rf.ddl.vipchild.service.BootService" >
</service>
</application>
</manifest>
当我关闭我的应用程序我的服务也关闭我想创建服务启动启动和永不结束服务,重启我的设备bootreciver类没有启动应用程序服务,我无法找到它发生的原因。
答案 0 :(得分:-1)
使用已启动的服务并将其设为START_STICKY。有关更多帮助,请粘贴您的服务代码