Last active
August 29, 2015 13:57
-
-
Save jacksonfdam/9654747 to your computer and use it in GitHub Desktop.
BroadcastReceiver no Boot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Não esquecer de declarar no Manifesto---> | |
<uses-permission android:name="android.permission.INTERNET" /> | |
<uses-permission android:name="android.permission.VIBRATE" /> | |
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | |
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | |
... | |
<receiver android:name="BootReceiver" > | |
<intent-filter> | |
<action android:name="android.intent.action.BOOT_COMPLETED" /> | |
<category android:name="android.intent.category.HOME" /> | |
</intent-filter> | |
</receiver> | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.coderockr.testeandroid.jacksonfdam; | |
import android.content.BroadcastReceiver; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.sax.StartElementListener; | |
public class BootReceiver extends BroadcastReceiver { | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
if (intent.getAction().contentEquals(Intent.ACTION_BOOT_COMPLETED)) { | |
Intent service = new Intent(context, CatalogoService.class); | |
service.putExtra("SLEEP", 1000); | |
context.startService(service); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment