I've created a basic activity for Google Glass, but it will not allow me to use the standard down swipe to go back in the stack to the previous activity. I've tried giving the activity focus with this code:
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.layout_orienation_detection_activity);
mView = getWindow().getDecorView().findViewById(android.R.id.content);
mView.setFocusable(true);
mView.setFocusableInTouchMode(true);
}
@Override
protected void onStart() {
super.onStart();
mGestureDetector = createGestureDetector(this);
serviceIntent = new Intent(this, SensorService.class);
startService(serviceIntent);
mView.requestFocus();
}
I've also tried creating my own down swipe features using the onKeyDown() method, and I've tried creating a Gesture detector for both TAP and SWIPE_DOWN, and then adding finish() to their respective callbacks. My gesture and key detector code looks exactly the same as the code on the Google Developers site at https://developers.google.com/glass/develop/gdk/touch, but still nothing works. I figure this shouldn't be necessary anyways, as Glass's standard back swipe ought to work anyways.
I don't know if this has anything to do with it, but my activity starts a service.
Also, sometimes it works the first time after I install the application, but then it stops working immediately after that.
Does anyone have any ideas as to what the problem is? It's very frustrating having to turn off the glass device or wait for the screen to timeout in order to exit the activity.
EDIT: The problem is with starting a service from the activity, as when I deleted the startService(intent) call from my activity, the down swiping worked fine. So how can I still run the background service, but also be able to down swipe?