コード例 #1
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   if (!mNavigationDrawerFragment.isDrawerOpen()) {
     getMenuInflater().inflate(R.menu.share_menu, menu);
     restoreActionBar();
     return true;
   }
   return super.onCreateOptionsMenu(menu);
 }
コード例 #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);
    mNavigationDrawerFragment =
        (NavigationDrawerFragment)
            getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
    mTitle = getTitle();

    // Set up the drawer.
    mNavigationDrawerFragment.setUp(
        R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout));

    FragmentManager fragmentManager = getFragmentManager();
    // GlobalFeedFragment feedFragment = new GlobalFeedFragment();
    // fragmentManager.beginTransaction().replace(R.id.container, feedFragment).commit();

    mStepValue = 0;
    mPaceValue = 0;

    startService(new Intent(this, Time.class));
    Log.i(TAG, "Started service");

    try {
      if (!mIsRunning) {
        p1_button.setText("Start ►");
        // p1_button.setBackgroundResource(R.drawable.resume);
      } else if (mIsRunning) {
        p1_button.setText("Stop ◼");
        // p1_button.setBackgroundResource(R.drawable.pause);

      }
    } catch (NullPointerException e) {

    }

    mPedometerUtils = PedometerUtils.getInstance();

    RebootSteps = (TextView) findViewById(R.id.time);
    RS = (TextView) findViewById(R.id.textView8);

    PackageManager m = getPackageManager();
    if (!m.hasSystemFeature(PackageManager.FEATURE_SENSOR_STEP_COUNTER)) {
      RS.setVisibility(View.INVISIBLE);
      RebootSteps.setVisibility(View.INVISIBLE);
    }

    mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    mStepCounterSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
    mStepDetectorSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR);
  }