Ejemplo n.º 1
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.menu_scan) {
      fragment.startScan();
      return true;
    }
    if (id == R.id.menu_stop) {
      fragment.stopScan();
      return true;
    }

    if (id == android.R.id.home) {
      NavUtils.navigateUpFromSameTask(this);
      return true;
    }

    invalidateOptionsMenu();
    return true;
  }
Ejemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scan);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    FragmentManager fm = getFragmentManager();
    FragmentTransaction fragmentTransaction = fm.beginTransaction();

    fragment = new MarshmallowBleScannerFragment();

    fragment.setCallback(scanCallback);

    fragmentTransaction.add(R.id.fragment_container, fragment);
    fragmentTransaction.commit();
  }