启动后服务无法启动

时间:2014-07-08 16:48:21

标签: android service bootcompleted

我在我的Android应用程序中有一项服务,如果我手动启动它可以正常工作,但我需要该服务才能启动启动,我无法在重新启动手机后自动启动它,我尝试了几个教程但没有任何工作

这是我的清单代码:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tvshowsguide"
android:versionCode="1"
android:versionName="1.0"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<application

    <service android:name="androidservice.SyncService" />

    <receiver android:name="androidservice.SyncAuto" >
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>
</application>

</manifest>

这是BroadcastReceiver代码:

public class SyncAuto extends BroadcastReceiver {
        public void onReceive(Context context, Intent intent) {

            Intent SyncService = new Intent(context, SyncService.class).setAction(SRVC);
            context.startService(SyncService);
        }
    }
}

1 个答案:

答案 0 :(得分:0)

我认为问题必须是您服务的参考,因为您有一个

的应用程序
 package="com.tvshowsguide"

您的服务和接收方必须具有以下名称:

 <service android:name="com.tvshowsguide.androidservice.SyncService" />
 <receiver android:name="com.tvshowsguide.androidservice.SyncAuto" >
相关问题