I am participating in a project that makes an extension of a augmented reality application using the smarteyeglass, and I've got a problem. I do not know why when I press the back button on the smarteyeglass I can't get the KEY_EVENT
"onReceive: com.sonyericsson.extras.aef.control.KEY_EVENT" instead of it i receive "onReceive: com.sonyericsson.extras.aef.control.TOUCH_EVENT" and "onReceive: com.sonyericsson.extras.aef.control.PAUSE" and "onReceive: com.sonyericsson.extras.aef.control.STOP".
So I used the sample code AdvancedLayouts and it works. I don't know what I'm doing wrong. The code to get the key event is the same as AdvancedLayouts's key event code.
I have the Key_Event added on AndroidManifest.xml
@Override
public void onKey(final int action, final int keyCode, final long timeStamp) {
if (action == Intents.KEY_ACTION_RELEASE && keyCode == Control.KeyCodes.KEYCODE_BACK) {
Log.d(Constants.LOG_TAG, "onKey() - back button intercepted.");
return;
}
if (!showingDetail) {
stopRequest();
}
}
You can use HelloEvents sample to see KeyEvent for back button quickly.
If you would like to implement it in your own project, please check following implementations are in place in your project.
@Override public boolean controlInterceptsBackButton() { return true; }
Have KeyEvent in your manifest
< action android:name="com.sonyericsson.extras.aef.control.KEY_EVENT" />
(Optional) Since your app will be receiving back button event, you need to handle application exit by calling stopRequest(). For example, AdvancedLayout calls this exit method, when user is in main menu of the app and taps back button.