开发者

I can not start my receiver

开发者 https://www.devze.com 2023-03-28 05:05 出处:网络
I never reach BootReceiver?? In my manifest i have: <receiver android:name=\".app.service.receiver.BootReceiver\" android:enabled=\"true\">

I never reach BootReceiver?? In my manifest i have:

 <receiver android:name=".app.service.receiver.BootReceiver" android:enabled="true">            
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <category android:name="android.intent.category.HOME" />
        </intent-filter>
    </receiver>
    <service android:name=".app.service.Process">
        <intent-filter>
            <action android:name=".app.service.Process" />
        </intent-filter>
    </service>

at my BootReceiver I have:

package cc.com.app.service.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class BootReceiver extends BroadcastReceiver {

@Override
public void onRe开发者_C百科ceive(Context context, Intent intent) {
    Intent serviceIntent = new Intent();

    serviceIntent.setAction("cc.com.service.Process");

    context.startService(serviceIntent);
}
}


Did you include the RECEIVE_BOOT_COMPLETED permission in your manifest file?

Update: Found something in What does it mean "No Launcher activity found!". You should be able to define the service as MAIN and LAUNCHER, both seem to be mandatory. Didn't know that either.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号