Android Open Source - GoogleGlass-XE16-LowFrequencyLiveCardBasketballScore Menu Activity






From Project

Back to project page GoogleGlass-XE16-LowFrequencyLiveCardBasketballScore.

License

The source code is released under:

Apache License

If you think the Android project GoogleGlass-XE16-LowFrequencyLiveCardBasketballScore listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.digitalconstruction.LowFrequencyLiveCardBasketballScore;
//from   w w w .j ava  2  s  .c  o  m
import android.app.Activity;
import android.content.Intent;
import android.os.Handler;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

public class MenuActivity extends Activity {

    private final Handler mHandler = new Handler();

    @Override
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        openOptionsMenu();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.basketballscore, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle item selection.
        switch (item.getItemId()) {
            case R.id.stop:
                // Stop the service at the end of the message queue for proper options menu
                // animation. This is only needed when starting a new Activity or stopping a Service
                // that published a LiveCard.
                post(new Runnable() {

                    @Override
                    public void run() {
                        stopService(new Intent(MenuActivity.this, LiveCardService.class));
                    }
                });
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    @Override
    public void onOptionsMenuClosed(Menu menu) {
        // Nothing else to do, closing the Activity.
        finish();
    }

    /**
     * Posts a {@link Runnable} at the end of the message loop, overridable for testing.
     */
    protected void post(Runnable runnable) {
        mHandler.post(runnable);
    }

}




Java Source Code List

com.digitalconstruction.LowFrequencyLiveCardBasketballScore.LiveCardService.java
com.digitalconstruction.LowFrequencyLiveCardBasketballScore.MenuActivity.java