Android Register Broadcast and using it

this is usually set onStart and onStop in activity

onStart you register Receiver

this.registerReceiver(lockBroadcastReceiver, new IntentFilter(BroadCastConstant.LOCK_BROAD_CAST));

onStop you unregister Receiver


and Receiver sample Class
this is just example

private BroadcastReceiver lockBroadcastReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {

String  initial = intent.getStringExtra("initial");
String  url = intent.getStringExtra("url");

if(initial == null)return;
if(url == null)return;

callAdStatistic(url, initial);

when you call it you can add parameters

Intent intent = new Intent();
intent.putExtra("initial", initial);
intent.putExtra("url", url);


Popular posts from this blog

Project euler 169 found clue

Floyd-Warshall's algorithm