How to receive Broadcasts

function OnStart() {

app.EnableBackKey( false );

app.SetOnBroadcast( rb ,"android.intent.action.HEADSET_PLUG");
app.SetOnBroadcast( rb ,"android.intent.action.SOUND_SETTINGS");
app.SetOnBroadcast( rb ,"android.media.VOLUME_CHANGED_ACTION");
app.SetOnBroadcast( rb ,"android.intent.action.TIME_TICK");
app.SetOnBroadcast( rb ,"android.AccessibilityService.FINGERPRINT_GESTURE_SWIPE_DOWN");
app.SetOnBroadcast( rb ,"android.action.CAMERA_BUTTON");
app.SetOnBroadcast( rb ,"android.action.MEDIA_BUTTON");

app.SetOnBroadcast( rb ,"android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED")
//app.SetOnBroadcast( rb ,"android.bluetooth.a2dp.profile.action.PLAYING_STATE_CHANGED")
app.SetOnBroadcast( rb ,"android.bluetooth.adapter.action.CONNECTION_STATE_CHANGED")
app.SetOnBroadcast( rb ,"android.bluetooth.adapter.action.DISCOVERY_FINISHED")
app.SetOnBroadcast( rb ,"android.bluetooth.adapter.action.DISCOVERY_STARTED")
app.SetOnBroadcast( rb ,"android.bluetooth.adapter.action.LOCAL_NAME_CHANGED")
app.SetOnBroadcast( rb ,"android.bluetooth.adapter.action.SCAN_MODE_CHANGED")
app.SetOnBroadcast( rb ,"android.bluetooth.adapter.action.STATE_CHANGED")
app.SetOnBroadcast( rb ,"android.bluetooth.device.action.ACL_CONNECTED")
app.SetOnBroadcast( rb ,"android.bluetooth.device.action.ACL_DISCONNECTED")
app.SetOnBroadcast( rb ,"android.bluetooth.device.action.ACL_DISCONNECT_REQUESTED")
app.SetOnBroadcast( rb ,"android.bluetooth.device.action.BOND_STATE_CHANGED")
app.SetOnBroadcast( rb ,"android.bluetooth.device.action.CLASS_CHANGED")
app.SetOnBroadcast( rb ,"android.bluetooth.device.action.FOUND")
app.SetOnBroadcast( rb ,"android.bluetooth.device.action.NAME_CHANGED")
app.SetOnBroadcast( rb ,"android.bluetooth.device.action.UUID")
app.SetOnBroadcast( rb ,"android.bluetooth.devicepicker.action.DEVICE_SELECTED")
app.SetOnBroadcast( rb ,"android.bluetooth.devicepicker.action.LAUNCH")
app.SetOnBroadcast( rb ,"android.bluetooth.headset.action.VENDOR_SPECIFIC_HEADSET_EVENT")
app.SetOnBroadcast( rb ,"android.bluetooth.headset.profile.action.AUDIO_STATE_CHANGED")
app.SetOnBroadcast( rb ,"android.bluetooth.headset.profile.action.CONNECTION_STATE_CHANGED")
app.SetOnBroadcast( rb ,"android.bluetooth.input.profile.action.CONNECTION_STATE_CHANGED")
app.SetOnBroadcast( rb ,"android.bluetooth.pan.profile.action.CONNECTION_STATE_CHANGED")

}

function rb(type,msg)
{
alert(JSON.stringify(type));
//alert(JSON.stringify(msg ));

}

function handleReply( error, reply ) {
alert(JSON.stringify(error));
alert(JSON.stringify(reply ));
}

function OnBack() {
  app.ToFront();
} // OnBack

function OnPause() {
	app.ToFront();
}