KeymappingReceiver extends BroadcastReceiver {
private static final String TAG = "KeymappingReceiver";
private static final String EXTRA_KEY_PRESS_TIMESTAMP = "com.samsung.android.knox.extra.EVENT_TIMESTAMP";
private static final String ACTION_SIDE_KEY_PRESS_DOWN = "com.samsung.android.knox.intent.action.SIDE_PRESS";
private static final String ACTION_SIDE_KEY_PRESS_UP = "com.samsung.android.knox.intent.action.SIDE_RELEASE";
@Override
public void onReceive(Context context, Intent intent) {
Log.i(TAG, "@onReceive - " + intent.getAction());
if (intent != null && intent.getAction() != null) {
//For custom intent, need to use intent action to distinguish key and action type
long timeStamp = intent.getLongExtra(EXTRA_KEY_PRESS_TIMESTAMP, -1L);
if (ACTION_SIDE_KEY_PRESS_DOWN.equalsIgnoreCase(intent.getAction())) {
// Side key is pressed, your code here
Log.i(TAG, “Side key pressed");
} else if (ACTION_SIDE_KEY_PRESS_UP.equalsIgnoreCase(intent.getAction())) {
// Side key is released, your code here
Log.i(TAG, “Side key released");
}
}
}//onReceive