Back to project page gdk-level-sample.
The source code is released under:
Apache License
If you think the Android project gdk-level-sample listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Copyright (C) 2013 Google Inc.// w w w. j a v a 2 s .com * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.google.android.glass.sample.level; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; /** * This activity manages the options menu that appears when the user taps on the Live Card. */ public class LevelMenuActivity extends Activity { private boolean mResumed; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override protected void onResume() { super.onResume(); mResumed = true; openOptionsMenu(); } @Override protected void onPause() { super.onPause(); mResumed = false; } @Override public void openOptionsMenu() { if (mResumed) { super.openOptionsMenu(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.level_live_card, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.stop: stopService(new Intent(this, LevelService.class)); return true; default: return super.onOptionsItemSelected(item); } } @Override public void onOptionsMenuClosed(Menu menu) { super.onOptionsMenuClosed(menu); // We must call finish() from this method to ensure that the activity ends either when an // item is selected from the menu or when the menu is dismissed by swiping down. finish(); } }