Last active
April 6, 2016 13:54
-
-
Save rwoloszyn/bdbd2594972d351c3aaa to your computer and use it in GitHub Desktop.
Register broadcastreceiver if debug
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
/** | |
* Test broadcast receiver used only for debug | |
*/ | |
private BroadcastReceiver testTransitStateReceiver = new BroadcastReceiver() { | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
logger.debug("Entry"); | |
Log.d("SomeReceiver", "testTransitStateReceiver"); | |
if(TEST_ACTION.equals(intent.getAction())){ | |
String extras = intent.getStringExtra("state"); | |
if("S".equals(extras)){ | |
onTransitStateChanged(TransitState.STATIONARY); | |
} else if ("T".equals(extras)){ | |
onTransitStateChanged(TransitState.IN_TRANSIT); | |
} else if ("U".equals(extras)){ | |
onTransitStateChanged(TransitState.UNKNOWN); | |
} | |
} | |
} | |
}; | |
//Test receiver are only for debug build config | |
if(BuildConfig.DEBUG){ | |
IntentFilter intentFilter = new IntentFilter(); | |
intentFilter.addAction(TEST_ACTION); | |
this.mContext.registerReceiver(testTransitStateReceiver,intentFilter); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
and sending broadcast from ADB could be made similar to this:
am broadcast "intent:#Intent;action=android.intent.action.BATTERY_CHANGED;i.status=5;i.voltage=4155;i.level=100;end"