开发者

Scheduling tasl on BOOT_COMPLETED

I have written next broadcast receiver for BOOT_COMPLETED action

public class FineWeatherBootStarter extends BroadcastReceiver {
PendingIntent pendingIntent = null;

public void onReceive(Context context, Intent intent) {

    long firstTime = System.currentTimeMillis();
    Intent serviceIntent = new Intent(FineWeather.ACTION_REFRESH);
    intent.setType(Weather.CONTENT_TYPE);
    pendingIntent = PendingIntent.getService(context, 0,serviceIntent, 0);
    AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    am.setRepeating(AlarmManager.RTC,
                    firstTime, 30*1000, pendingIntent);
    Toast.makeText(context, "STARTED!!!!!!!!!", 5000).show();
}

}

I can see "STARTED!!!!!!!!!" message on boot device, but my service seems like not being started eve开发者_StackOverflowry 30 seconds

Where can be a probleb&


Try altering your manifest

<receiver android:name="MyBootReceiver" android:process=":hascode_process">
        <intent-filter >
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.USER_PRESENT" />
        </intent-filter>
    </receiver>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜