Last active
August 29, 2015 14:13
-
-
Save SelvinPL/6616c027b18d413b48a1 to your computer and use it in GitHub Desktop.
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 pl.selvin.android.broadcastkilled; | |
import android.app.Activity; | |
import android.app.Notification; | |
import android.content.BroadcastReceiver; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.content.IntentFilter; | |
import android.os.Bundle; | |
import android.util.Log; | |
public class MainActivity extends Activity { | |
final static String ACTION = "pl.selvin.android.broadcastkilled"; | |
final static String TAG = "broadcastkilled.MainActivity"; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
} | |
BroadcastReceiver reciver = null; | |
@Override | |
protected void onStart() { | |
super.onStart(); | |
Log.d(TAG, "onStart"); | |
reciver = new BroadcastReceiver() { | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
Log.d(TAG, "BroadcastReceiver.onReceive(...)"); | |
} | |
}; | |
final IntentFilter filter = new IntentFilter(ACTION); | |
registerReceiver(reciver, filter); | |
} | |
@Override | |
protected void onStop() { | |
Log.d(TAG, "onStop"); | |
if (reciver != null) | |
unregisterReceiver(reciver); | |
super.onStop(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment