2

Android BroadcastReceiver

Untuk bagian broadcast:

Intent intent = new Intent();
intent.setAction(receiver);
intent.putExtra("pagi","Selamat pagi.");
sendBroadcast(intent);

Untuk bagian receiver:

// Buat receiver.
BroadcastReceiver bReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        String str = intent.getStringExtra("pagi");
        Log.d(TAG,str);
    }
};
// Buat filter.
IntentFilter filter = new IntentFilter();
filter.addAction(receiver);
// Daftarkan receiver dan filter.
registerReceiver(bReceiver,filter);

 

Source code:
download