Example #1
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   boolean handled = false;
   Intent intent;
   switch (item.getItemId()) {
     case MENU_GRAPHTYPE:
       showDialog(DIALOG_GRAPHTYPE);
       handled = true;
       break;
     case MENU_TRACKLIST:
       intent = new Intent(this, TrackList.class);
       intent.putExtra(Tracks._ID, mTrackUri.getLastPathSegment());
       startActivityForResult(intent, MENU_TRACKLIST);
       break;
     case MENU_SHARE:
       intent = new Intent(Intent.ACTION_RUN);
       intent.setDataAndType(mTrackUri, Tracks.CONTENT_ITEM_TYPE);
       intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
       Bitmap bm = mViewFlipper.getDrawingCache();
       Uri screenStreamUri = ShareTrack.storeScreenBitmap(bm);
       intent.putExtra(Intent.EXTRA_STREAM, screenStreamUri);
       startActivityForResult(
           Intent.createChooser(intent, getString(R.string.share_track)), MENU_SHARE);
       handled = true;
       break;
     default:
       handled = super.onOptionsItemSelected(item);
   }
   return handled;
 }
Example #2
0
 /*
  * (non-Javadoc)
  * @see android.app.Activity#onActivityResult(int, int, android.content.Intent)
  */
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
   super.onActivityResult(requestCode, resultCode, intent);
   switch (requestCode) {
     case MENU_TRACKLIST:
       if (resultCode == RESULT_OK) {
         mTrackUri = intent.getData();
         drawTrackingStatistics();
       }
       break;
     case MENU_SHARE:
       ShareTrack.clearScreenBitmap();
       break;
     default:
       Log.w(TAG, "Unknown activity result request code");
   }
 }