List of usage examples for android.content Intent getParcelableExtra
public <T extends Parcelable> T getParcelableExtra(String name)
From source file:com.gmail.taneza.ronald.carbs.myfoods.MyFoodsEditableFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (resultCode) { case MyFoodDetailsActivity.MY_FOOD_RESULT_OK: FoodItemInfo foodItemInfo = data.getParcelableExtra(MyFoodDetailsActivity.MY_FOOD_ITEM_INFO_RESULT); if (requestCode == MyFoodDetailsActivity.Mode.NewFood.ordinal()) { mFoodDbAdapter.addMyFoodItemInfo(foodItemInfo); } else {//from w w w . ja v a 2s. c om mFoodDbAdapter.updateMyFoodItemInfo(foodItemInfo); } restartLoader(); mMyFoodsActivityNotifier.setItemChanged(); break; case MyFoodDetailsActivity.MY_FOOD_RESULT_DELETE: FoodItem foodItem = data.getParcelableExtra(MyFoodDetailsActivity.MY_FOOD_ITEM_RESULT); mFoodDbAdapter.deleteMyFoodItem(foodItem); restartLoader(); mMyFoodsActivityNotifier.setItemDeleted(); break; } }
From source file:com.ddj.launcher2.InstallShortcutReceiver.java
public void onReceive(Context context, Intent data) { if (!ACTION_INSTALL_SHORTCUT.equals(data.getAction())) { return;/*from ww w .j a va 2 s . c o m*/ } Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); if (intent == null) { return; } // This name is only used for comparisons and notifications, so fall back to activity name // if not supplied String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); if (name == null) { try { PackageManager pm = context.getPackageManager(); ActivityInfo info = pm.getActivityInfo(intent.getComponent(), 0); name = info.loadLabel(pm).toString(); } catch (PackageManager.NameNotFoundException nnfe) { return; } } Bitmap icon = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON); Intent.ShortcutIconResource iconResource = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE); // Queue the item up for adding if launcher has not loaded properly yet boolean launcherNotLoaded = LauncherModel.getCellCountX() <= 0 || LauncherModel.getCellCountY() <= 0; PendingInstallShortcutInfo info = new PendingInstallShortcutInfo(data, name, intent); info.icon = icon; info.iconResource = iconResource; if (mUseInstallQueue || launcherNotLoaded) { String spKey = LauncherUtil.getSharedPreferencesKey(); SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE); addToInstallQueue(sp, info); } else { processInstallShortcut(context, info); } }
From source file:com.appmanager.android.app.DetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); setupActionBar();/*from w ww.j a v a 2 s.c o m*/ mFileEntry = null; Intent intent = getIntent(); Button deleteButton = (Button) findViewById(R.id.delete); if (intent != null) { if (intent.hasExtra(EXTRA_FILE_ENTRY)) { mFileEntry = intent.getParcelableExtra(EXTRA_FILE_ENTRY); if (mFileEntry != null) { restoreValues(mFileEntry); } } else { ((EditText) findViewById(R.id.url)).setText(DEFAULT_URL); deleteButton.setEnabled(false); } } findViewById(R.id.download).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { confirmDownload(); } }); findViewById(R.id.save).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { save(); } }); deleteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { confirmDelete(); } }); }
From source file:com.google.android.gms.samples.vision.face.facetracker.ui.activity.FaceTrackerActivity.java
/** * Initializes the UI and initiates the creation of a face detector. *//*from w ww. j a va 2s .c om*/ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main); new PosterLinkLoader().start("interstellar"); // new PosterLinkLoader().getLink("interstellar"); // Bitmap bitmap = new PosterLoader().getThumb("w500", "/nBNZadXqJSdt05SHLqgT0HuC5Gm.jpg"); mPreview = (CameraSourcePreview) findViewById(R.id.preview); mGraphicOverlay = (GraphicOverlay) findViewById(R.id.faceOverlay); findViewById(R.id.capture).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mCameraSource.takePicture(null, pictureCallback); } }); // Check for the camera permission before accessing the camera. If the // permission is not granted yet, request permission. int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA); if (rc == PackageManager.PERMISSION_GRANTED) { createCameraSource(); } else { requestCameraPermission(); } Intent intent = getIntent(); poster = intent.getParcelableExtra("poster"); // String fullSizePosterLink = MoviePosterUrl.getPosterUrl(poster.getImagePath(), MoviePosterUrl.MoviePosterSize.ORIGINAL); // Bitmap fullSizePoster = ((MyApplication) getApplication()).getBitmap(); // Bitmap overlayedPoster = FaceReplace.replaceOneFace(fullSizePoster, mCurrentBitmap); }
From source file:com.mbientlab.metawear.app.ModuleActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case START_MODULE_DETAIL: case DFU://from w w w . j a v a 2 s . c o m device = data.getParcelableExtra(EXTRA_BLE_DEVICE); if (device != null) { mwController = mwService.getMetaWearController(device); } break; case REQUEST_ENABLE_BT: if (resultCode == Activity.RESULT_CANCELED) { finish(); } break; } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.bayapps.android.robophish.ui.FullScreenPlayerActivity.java
private void updateFromParams(Intent intent) { if (intent != null) { MediaDescriptionCompat description = intent .getParcelableExtra(MusicPlayerActivity.EXTRA_CURRENT_MEDIA_DESCRIPTION); if (description != null) { //updateMediaDescription(description); //FIXME: is this necessary?? }/*w ww .ja v a 2 s . co m*/ } }
From source file:com.almunt.jgcaap.systemupdater.DownloadService.java
@Override protected void onHandleIntent(Intent intent) { String urlToDownload = "http://download.jgcaap.xyz/files/oneplusone/cm-13.0/" + intent.getStringExtra("url"); filename = intent.getStringExtra("url"); String newfilename = filename.replace("zip", "temp"); ResultReceiver receiver = (ResultReceiver) intent.getParcelableExtra("receiver"); try {/*w w w . ja v a 2 s . c om*/ URL url = new URL(urlToDownload); URLConnection connection = url.openConnection(); connection.connect(); // this will be useful so that you can show a typical 0-100% progress bar int fileLength = connection.getContentLength(); // download the file InputStream input = new BufferedInputStream(connection.getInputStream()); File tempDir = new File(Environment.getExternalStorageDirectory() + "/JgcaapUpdates/temp/"); tempDir.mkdir(); //make a folder for downloading files OutputStream output = new FileOutputStream( Environment.getExternalStorageDirectory() + "/JgcaapUpdates/temp/" + newfilename); byte data[] = new byte[1024]; long total = 0; int count; File temp = new File(Environment.getExternalStorageDirectory() + "/JgcaapUpdates/temp/nd"); //temp file is created in case of an error while ((count = input.read(data)) != -1 && continuedownload) { total += count; // publishing the progress.... Bundle resultData = new Bundle(); resultData.putInt("progress", (int) total); resultData.putInt("total", fileLength); resultData.putString("filename", filename); resultData.putBoolean("error", false); receiver.send(UPDATE_PROGRESS, resultData); output.write(data, 0, count); if (temp.exists()) { continuedownload = false; temp.delete(); } } output.flush(); output.close(); input.close(); } catch (IOException e) { System.out.println(e.getMessage()); Bundle resultData = new Bundle(); resultData.putInt("progress", 0); resultData.putInt("total", 1); resultData.putString("filename", filename); resultData.putBoolean("error", true); resultData.putString("errordetails", e.getMessage()); receiver.send(UPDATE_PROGRESS, resultData); } String dir = Environment.getExternalStorageDirectory() + File.separator + "JgcaapUpdates"; // copy downloaded file if download is successful if (continuedownload) { try { if (new File(Environment.getExternalStorageDirectory() + "/JgcaapUpdates/temp/" + newfilename) .length() > 1000) copy(new File(Environment.getExternalStorageDirectory() + "/JgcaapUpdates/temp/" + newfilename), new File(Environment.getExternalStorageDirectory() + "/JgcaapUpdates/" + filename)); } catch (IOException e) { e.printStackTrace(); } Bundle resultData = new Bundle(); resultData.putInt("progress", 100); receiver.send(UPDATE_PROGRESS, resultData); } //clear the temporary folder File deletefolder = new File(dir + "/temp"); if (deletefolder.exists()) { File[] contents = deletefolder.listFiles(); if (contents != null) { for (File f : contents) { f.delete(); } } } deletefolder.delete(); }
From source file:com.shanet.relayremote.Main.java
public void onNewIntent(Intent intent) { // When an NFC tag is being written, call the write tag function when an intent is // received that says the tag is within range of the device and ready to be written to Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); String nfcMessage = intent.getStringExtra("nfcMessage"); if (nfcMessage != null) { NFC.writeTag(this, tag, nfcMessage); }// w ww . j av a 2s. c o m }
From source file:com.appdevper.mediaplayer.activity.FullScreenPlayerActivity.java
private void updateFromParams(Intent intent) { if (intent != null) { MediaDescriptionCompat description = intent .getParcelableExtra(MainActivity.EXTRA_CURRENT_MEDIA_DESCRIPTION); if (description != null) { updateMediaDescription(description); }/*from ww w. j a v a 2 s . c o m*/ } }
From source file:com.example.evan.comp296.profile.MainActivity_Profile.java
private void onUploadResultIntent(Intent intent) throws IOException { // Got a new intent from MyUploadService with a success or failure mDownloadUrl = intent.getParcelableExtra(MyUploadService.EXTRA_DOWNLOAD_URL); mFileUri = intent.getParcelableExtra(MyUploadService.EXTRA_FILE_URI); updateUI(mAuth.getCurrentUser());//from w w w. j a v a 2 s . c o m }