List of usage examples for android.content Intent getParcelableExtra
public <T extends Parcelable> T getParcelableExtra(String name)
From source file:org.klnusbaum.udj.network.EventCommService.java
@Override public void onHandleIntent(Intent intent) { Log.d(TAG, "In Event Comm Service"); AccountManager am = AccountManager.get(this); final Account account = (Account) intent.getParcelableExtra(Constants.ACCOUNT_EXTRA); if (intent.getAction().equals(Intent.ACTION_INSERT)) { enterEvent(intent, am, account, true); } else if (intent.getAction().equals(Intent.ACTION_DELETE)) { //TODO handle if userId is null shouldn't ever be, but hey... leaveEvent(am, account, true);//from w w w . ja va 2 s . c o m } else { Log.d(TAG, "ACTION wasn't delete or insert, it was " + intent.getAction()); } }
From source file:net.peterkuterna.android.apps.devoxxsched.service.SyncService.java
@Override protected void onHandleIntent(Intent intent) { final ResultReceiver receiver = intent.getParcelableExtra(EXTRA_STATUS_RECEIVER); if (receiver != null) receiver.send(STATUS_RUNNING, Bundle.EMPTY); final Context context = this; final SharedPreferences syncServicePrefs = getSharedPreferences(SyncPrefs.DEVOXXSCHED_SYNC, Context.MODE_PRIVATE); final int localVersion = syncServicePrefs.getInt(SyncPrefs.LOCAL_VERSION, VERSION_NONE); final long lastRemoteSync = syncServicePrefs.getLong(SyncPrefs.LAST_REMOTE_SYNC, 0); try {//ww w . j a va 2 s. c o m // Bulk of sync work, performed by executing several fetches from // local and online sources. final long startLocal = System.currentTimeMillis(); final boolean localParse = localVersion < VERSION_LOCAL; Log.d(TAG, "found localVersion=" + localVersion + " and VERSION_LOCAL=" + VERSION_LOCAL); if (localParse) { // Parse values from local cache first mLocalExecutor.execute(R.xml.search_suggest, new LocalSearchSuggestHandler()); mLocalExecutor.execute(context, "cache-rooms.json", new RemoteRoomsHandler()); mLocalExecutor.execute(context, "cache-presentationtypes.json", new RemoteSessionTypesHandler()); mLocalExecutor.execute(context, "cache-speakers.json", new RemoteSpeakersHandler()); mLocalExecutor.execute(context, "cache-presentations.json", new RemoteSessionsHandler()); mLocalExecutor.execute(context, "cache-schedule.json", new RemoteScheduleHandler()); // Save local parsed version syncServicePrefs.edit().putInt(SyncPrefs.LOCAL_VERSION, VERSION_LOCAL).commit(); } Log.d(TAG, "local sync took " + (System.currentTimeMillis() - startLocal) + "ms"); final long startRemote = System.currentTimeMillis(); boolean performRemoteSync = performRemoteSync(mResolver, mHttpClient, intent, context); if (performRemoteSync) { // Parse values from REST interface ArrayList<RequestHash> result = mRemoteExecutor.executeGet(new String[] { Constants.ROOMS_URL, }, new RemoteRoomsHandler()); for (RequestHash requestHash : result) { SyncUtils.updateLocalMd5(mResolver, requestHash.getUrl(), requestHash.getMd5()); } result = mRemoteExecutor.executeGet(new String[] { Constants.LABS_PRESENTATION_TYPES_URL, }, new RemoteSessionTypesHandler()); for (RequestHash requestHash : result) { SyncUtils.updateLocalMd5(mResolver, requestHash.getUrl(), requestHash.getMd5()); } result = mRemoteExecutor.executeGet( new String[] { Constants.SPEAKERS_URL, Constants.LABS_SPEAKERS_URL, }, new RemoteSpeakersHandler()); for (RequestHash requestHash : result) { SyncUtils.updateLocalMd5(mResolver, requestHash.getUrl(), requestHash.getMd5()); } result = mRemoteExecutor.executeGet( new String[] { Constants.PRESENTATIONS_URL, Constants.LABS_PRESENTATIONS_URL, }, new RemoteSessionsHandler()); for (RequestHash requestHash : result) { SyncUtils.updateLocalMd5(mResolver, requestHash.getUrl(), requestHash.getMd5()); } result = mRemoteExecutor.executeGet( new String[] { Constants.SCHEDULE_URL, Constants.LABS_SCHEDULE_URL, }, new RemoteScheduleHandler()); for (RequestHash requestHash : result) { SyncUtils.updateLocalMd5(mResolver, requestHash.getUrl(), requestHash.getMd5()); } // Save last remote sync time syncServicePrefs.edit().putLong(SyncPrefs.LAST_REMOTE_SYNC, startRemote).commit(); // Save remote parsed version syncServicePrefs.edit().putInt(SyncPrefs.LOCAL_VERSION, VERSION_REMOTE).commit(); } Log.d(TAG, "remote sync took " + (System.currentTimeMillis() - startRemote) + "ms"); if (!localParse && performRemoteSync) { NotificationUtils.cancelNotifications(context); NotificationUtils.notifyNewSessions(context, getContentResolver()); NotificationUtils.notifyChangedStarredSessions(context, getContentResolver()); } } catch (Exception e) { Log.e(TAG, "Problem while syncing", e); if (receiver != null) { // Pass back error to surface listener final Bundle bundle = new Bundle(); bundle.putString(Intent.EXTRA_TEXT, e.toString()); receiver.send(STATUS_ERROR, bundle); } } // Announce success to any surface listener Log.d(TAG, "sync finished"); if (receiver != null) receiver.send(STATUS_FINISHED, Bundle.EMPTY); }
From source file:net.networksaremadeofstring.rhybudd.WriteNFCActivity.java
public void onNewIntent(Intent intent) { try {/*from w ww . j av a 2 s . co m*/ Tag tagFromIntent = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); WriteTag(tagFromIntent); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("WriteNFCActivity", "onNewIntent", e); } }
From source file:br.com.bioscada.apps.biotracks.io.file.importer.ImportActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); importAll = intent.getBooleanExtra(EXTRA_IMPORT_ALL, false); trackFileFormat = intent.getParcelableExtra(EXTRA_TRACK_FILE_FORMAT); if (trackFileFormat == null) { trackFileFormat = TrackFileFormat.GPX; }//from w ww .j ava 2 s . com if (!FileUtils.isExternalStorageAvailable()) { Toast.makeText(this, R.string.external_storage_not_available, Toast.LENGTH_LONG).show(); finish(); return; } String directoryPath; if (importAll) { directoryDisplayName = FileUtils.getPathDisplayName(trackFileFormat.getExtension()); directoryPath = FileUtils.getPath(trackFileFormat.getExtension()); if (!FileUtils.isDirectory(new File(directoryPath))) { Toast.makeText(this, getString(R.string.import_no_directory, directoryDisplayName), Toast.LENGTH_LONG).show(); finish(); return; } } else { String action = intent.getAction(); if (!(Intent.ACTION_ATTACH_DATA.equals(action) || Intent.ACTION_VIEW.equals(action))) { Log.d(TAG, "Invalid action: " + intent); finish(); return; } Uri data = intent.getData(); if (!UriUtils.isFileUri(data)) { Log.d(TAG, "Invalid data: " + intent); finish(); return; } directoryDisplayName = data.getPath(); directoryPath = data.getPath(); } Object retained = getLastNonConfigurationInstance(); if (retained instanceof ImportAsyncTask) { importAsyncTask = (ImportAsyncTask) retained; importAsyncTask.setActivity(this); } else { importAsyncTask = new ImportAsyncTask(this, importAll, trackFileFormat, directoryPath); importAsyncTask.execute(); } }
From source file:com.linkedin.android.shaky.Shaky.java
private Result unpackResult(Intent intent) { Result result = new Result(intent.getBundleExtra(FeedbackActivity.USER_DATA)); result.setScreenshotUri((Uri) intent.getParcelableExtra(FeedbackActivity.SCREENSHOT_URI)); result.setTitle(intent.getStringExtra(FeedbackActivity.TITLE)); result.setMessage(intent.getStringExtra(FeedbackActivity.MESSAGE)); // add file provider data to all attachments ArrayList<Uri> fileProviderAttachments = new ArrayList<>(); for (Uri attachment : result.getAttachments()) { fileProviderAttachments.add(Utils.getProviderUri(activity, attachment)); }// w ww .ja v a2s . c o m result.setAttachments(fileProviderAttachments); return result; }
From source file:agricultural.nxt.agriculturalsupervision.Activity.intercourse.SupplierAddUpdateActivity.java
@Override protected void initView() { Intent intent = getIntent(); String type = intent.getStringExtra("type"); supplier = intent.getParcelableExtra("supplier"); if ("update".equals(type)) { toolBar.setTitle("?"); isUpdate = true;/*from www . ja v a 2 s. co m*/ } else { toolBar.setTitle("?"); } toolBar.setLeftButtonIcon(ContextCompat.getDrawable(this, R.mipmap.icon_arrow_02)); toolBar.setLeftButtonOnClickLinster(v -> finish()); if (isUpdate) { et_vcmysuppliername.setText(supplier.getVcmysuppliername()); et_vccorporation.setText(supplier.getVccorporation()); et_vcphone.setText(supplier.getVcphone()); et_vcaddress.setText(supplier.getVcaddress()); et_vcemail.setText(supplier.getVcemail()); et_vcbizlicense.setText(supplier.getVcbizlicense()); tv_cbizlicedate.setText(supplier.getVcbizlicedate()); et_vcproductlicense.setText(supplier.getVcproductlicense()); tv_dtprodlicendate.setText(supplier.getDtprodlicendate()); if (null != supplier.getVcbizlicepic()) { String imgPath1 = supplier.getVcbizlicepic().substring(1, supplier.getVcbizlicepic().length()); img1.setVisibility(View.VISIBLE); Glide.with(this).load(Constants.IMG_HEAD + imgPath1).crossFade().into(img1); } if (null != supplier.getVcprodlicenpic()) { String imgpath2 = supplier.getVcprodlicenpic().substring(1, supplier.getVcprodlicenpic().length()); img2.setVisibility(View.VISIBLE); Glide.with(this).load(Constants.IMG_HEAD + imgpath2).crossFade().into(img2); } } // tv_cbizlicedate.setOnClickListener(v -> showTimePickDialog(tv_cbizlicedate)); tv_dtprodlicendate.setOnClickListener(v -> showTimePickDialog(tv_dtprodlicendate)); btnselect1.setOnClickListener(this); btnselect2.setOnClickListener(this); btnUpdateAdd.setOnClickListener(this); }
From source file:com.nbplus.vbroadlauncher.RealtimeBroadcastProxyActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); acquireCpuWakeLock();/* ww w . j a v a 2 s. c o m*/ IntentFilter filter = new IntentFilter(); filter.addAction(Constants.ACTION_BROADCAST_CHATHEAD_VIEW_DETACHED); LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, filter); hideSystemUI(); Intent i; Intent intent = getIntent(); mBroadcastPayloadIdx = System.currentTimeMillis(); if (intent != null) { PushPayloadData data = intent.getParcelableExtra(Constants.EXTRA_BROADCAST_PAYLOAD_DATA); if (data == null) { Log.d(TAG, ">>"); finish(); return; } if (Constants.PUSH_PAYLOAD_TYPE_TEXT_BROADCAST.equals(data.getServiceType())) { mcheckText2SpeechLister = this; checkText2SpeechAvailable(); } else { i = new Intent(this, BroadcastChatHeadService.class); i.putExtra(Constants.EXTRA_BROADCAST_PAYLOAD_INDEX, mBroadcastPayloadIdx); i.putExtra(Constants.EXTRA_BROADCAST_PAYLOAD_DATA, data); startService(i); } } }
From source file:com.google.android.gms.samples.vision.barcodereader.MainActivity.java
/** * Called when an activity you launched exits, giving you the requestCode * you started it with, the resultCode it returned, and any additional * data from it. The <var>resultCode</var> will be * {@link #RESULT_CANCELED} if the activity explicitly returned that, * didn't return any result, or crashed during its operation. * <p/>//from ww w. j a va 2 s . co m * <p>You will receive this call immediately before onResume() when your * activity is re-starting. * <p/> * * @param requestCode The integer request code originally supplied to * startActivityForResult(), allowing you to identify who this * result came from. * @param resultCode The integer result code returned by the child activity * through its setResult(). * @param data An Intent, which can return result data to the caller * (various data can be attached to Intent "extras"). * @see #startActivityForResult * @see #createPendingResult * @see #setResult(int) */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == RC_BARCODE_CAPTURE) { if (resultCode == CommonStatusCodes.SUCCESS) { if (data != null) { final Barcode barcode = data.getParcelableExtra(BarcodeCaptureActivity.BarcodeObject); statusMessage.setText(R.string.barcode_success); barcodeValue.setText(barcode.displayValue); Log.d(TAG, "Barcode read: " + barcode.displayValue); RequestQueue queue = Volley.newRequestQueue(this); StringRequest postRequest = new StringRequest(Request.Method.POST, "http://172.16.9.79/ingresoUTB/registro", new Response.Listener<String>() { @Override public void onResponse(String response) { Toast.makeText(MainActivity.this, "Error de conexin", LENGTH_SHORT).show(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(MainActivity.this, "Error de conexin", LENGTH_SHORT).show(); } }) { @Override protected Map<String, String> getParams() { Map<String, String> params = new HashMap<String, String>(); params.put("codigo", barcode.displayValue.toLowerCase()); params.put("autor", "celador"); return params; } @Override public Map<String, String> getHeaders() throws AuthFailureError { Map<String, String> params = new HashMap<String, String>(); params.put("Content-Type", "application/x-www-form-urlencoded"); return params; } }; queue.add(postRequest); } else { statusMessage.setText(R.string.barcode_failure); Log.d(TAG, "No barcode captured, intent data is null"); } } else { statusMessage.setText(String.format(getString(R.string.barcode_error), CommonStatusCodes.getStatusCodeString(resultCode))); } } else { super.onActivityResult(requestCode, resultCode, data); } }
From source file:com.mattprecious.prioritysms.receiver.AlarmReceiver.java
private void handleIntent(Context context, Intent intent) { if (!intent.hasExtra(Intents.EXTRA_PROFILE)) { missingExtra(Intents.EXTRA_PROFILE); }/*from w w w . j ava2s . c om*/ BaseProfile profile = intent.getParcelableExtra(Intents.EXTRA_PROFILE); if (Intents.ALARM_KILLED.equals(intent.getAction())) { boolean replaced = intent.getBooleanExtra(Intents.ALARM_REPLACED, false); if (!replaced) { // TODO: throw a notification saying it was auto-killed NotificationManager nm = getNotificationManager(context); nm.cancel(profile.getId()); // should be caught in the activity, but you can never have too // many stopServices! context.stopService(new Intent(Intents.ACTION_ALERT)); } return; } else if (!Intents.ACTION_ALERT.equals(intent.getAction())) { // Unknown intent, bail. return; } if (!intent.hasExtra(Intents.EXTRA_NUMBER)) { missingExtra(Intents.EXTRA_NUMBER); } else if (profile instanceof SmsProfile) { if (!intent.hasExtra(Intents.EXTRA_MESSAGE)) { missingExtra(Intents.EXTRA_MESSAGE); } } String number = intent.getStringExtra(Intents.EXTRA_NUMBER); String message = intent.getStringExtra(Intents.EXTRA_MESSAGE); Log.v(TAG, "Received alarm set for id=" + profile.getId()); if (profile.getActionType() == ActionType.ALARM) { doAlarm(context, profile, number, message); } else { doNotify(context, profile); } }
From source file:com.adobe.phonegap.csdk.ImageEditor.java
/** * Called when the image editor exits.//from w ww .j a v a2 s . co m * * @param requestCode The request code originally supplied to startActivityForResult(), * allowing you to identify who this result came from. * @param resultCode The integer result code returned by the child activity through its setResult(). * @param intent An Intent, which can return result data to the caller (various data can be attached to Intent "extras"). */ public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (resultCode == Activity.RESULT_OK) { switch (requestCode) { case 1: Uri editedImageUri = intent.getParcelableExtra(AdobeImageIntent.EXTRA_OUTPUT_URI); this.callbackContext.success(editedImageUri.toString()); break; } } else if (resultCode == Activity.RESULT_CANCELED) { this.callbackContext.error("Editor Canceled"); } }