List of usage examples for android.content Intent getParcelableExtra
public <T extends Parcelable> T getParcelableExtra(String name)
From source file:com.kaliturin.blacklist.fragments.SettingsFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { // default sms app dialog result case DEFAULT_SMS_APP: if (resultCode == Activity.RESULT_OK) { Permissions.invalidateCache(); }// w w w .j ava 2s . co m // reload list reloadListViewItems(); break; // ringtone picker dialog results default: // get ringtone url Uri uri = null; if (resultCode == Activity.RESULT_OK && data != null) { uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); } // save url as settings property value setRingtoneUri(requestCode, uri); break; } }
From source file:com.sean.takeastand.alarmprocess.AlarmService.java
private void beginStandNotifications(Intent intent) { mainActivityVisible = false;/*from w w w .j av a2s.c om*/ mHandler = new Handler(); checkMainActivityVisible(); sendNotification(); int defaultReminderTime = Utils.getNotificationReminderFrequency(AlarmService.this) * Constants.secondsInMinute * Constants.millisecondsInSecond; mHandler.postDelayed(timeToUpdateNotification, defaultReminderTime); if (intent.hasExtra(Constants.ALARM_SCHEDULE)) { mCurrentAlarmSchedule = intent.getParcelableExtra(Constants.ALARM_SCHEDULE); } if (mCurrentAlarmSchedule == null) { Utils.setImageStatus(this, Constants.NON_SCHEDULE_TIME_TO_STAND); } else { Utils.setImageStatus(this, Constants.SCHEDULE_TIME_TO_STAND); } }
From source file:com.bai.android.ui.OtherActivity.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == CHANGE_RINGTONE_REQUEST_CODE && resultCode == RESULT_OK) { Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); if (uri != null) { String ringTonePath = uri.toString(); SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SharedPreferences.Editor editor = pref.edit(); editor.putString(getResources().getString(R.string.default_sound), ringTonePath); editor.commit();//w w w .j a v a 2 s .co m pref = null; } } else { int rotation = ExifInterface.ORIENTATION_NORMAL; if (requestCode == GALLERY_IMAGE_ACTIVITY_REQUEST_CODE && resultCode == RESULT_OK && data.getData() != null) { Uri imageUri = data.getData(); setAvatarFromInputStreamUri(imageUri); rotation = getOrientationFromMediaStore(getApplicationContext(), imageUri); rotateImageIfNecessary(rotation); if (avatarPicture != null) { avatar.setImageBitmap(avatarPicture); } } else if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE && resultCode == RESULT_OK) { String imagePath = getSharedPreferences(SHR_PRF_APP_KEY, MODE_PRIVATE).getString(SHR_PRF_IMG_URI, null); setAvatarFromFilePath(imagePath); if (avatarPicture == null) { Toast.makeText(getApplicationContext(), "Image cannot be decoded", Toast.LENGTH_LONG).show(); return; } rotation = getOrientationFromFile(imagePath); // } rotateImageIfNecessary(rotation); if (avatarPicture != null) { avatar.setImageBitmap(avatarPicture); } } } }
From source file:com.pressurelabs.flowopensource.TheHubActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case AppConstants.EXPORT_RESOLVE_CONNECTION_REQUEST_CODE: if (resultCode == RESULT_OK) { mGoogleApiClient.connect();/*from w w w.ja va 2 s . c om*/ } break; case AppConstants.EXPORT_CREATOR_REQUEST_CODE: if (resultCode == RESULT_OK) { DriveId driveFileId = (DriveId) data .getParcelableExtra(OpenFileActivityBuilder.EXTRA_RESPONSE_DRIVE_ID); writeDataExportToFile(driveFileId); } break; default: super.onActivityResult(requestCode, resultCode, data); break; } }
From source file:com.google.android.gms.samples.wallet.FullWalletConfirmationButtonFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { mProgressDialog.hide();// ww w . jav a 2 s. c o m // retrieve the error code, if available int errorCode = -1; if (data != null) { errorCode = data.getIntExtra(WalletConstants.EXTRA_ERROR_CODE, -1); } switch (requestCode) { case REQUEST_CODE_RESOLVE_ERR: if (resultCode == Activity.RESULT_OK) { mGoogleApiClient.connect(); } else { handleUnrecoverableGoogleWalletError(errorCode); } break; case REQUEST_CODE_RESOLVE_LOAD_FULL_WALLET: switch (resultCode) { case Activity.RESULT_OK: if (data.hasExtra(WalletConstants.EXTRA_FULL_WALLET)) { FullWallet fullWallet = data.getParcelableExtra(WalletConstants.EXTRA_FULL_WALLET); // the full wallet can now be used to process the customer's payment // send the wallet info up to server to process, and to get the result // for sending a transaction status fetchTransactionStatus(fullWallet); } else if (data.hasExtra(WalletConstants.EXTRA_MASKED_WALLET)) { // re-launch the activity with new masked wallet information mMaskedWallet = data.getParcelableExtra(WalletConstants.EXTRA_MASKED_WALLET); mActivityLaunchIntent.putExtra(Constants.EXTRA_MASKED_WALLET, mMaskedWallet); startActivity(mActivityLaunchIntent); } break; case Activity.RESULT_CANCELED: // nothing to do here break; default: handleError(errorCode); break; } break; } }
From source file:com.github.dfa.diaspora_android.activity.MainActivity.java
/** * Share an image shared to the app via diaspora * * @param intent shareImageIntent//from www . j a v a 2 s.c o m */ //TODO: Implement some day private void handleSendImage(Intent intent) { AppLog.i(this, "handleSendImage()"); final Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (imageUri != null) { AppLog.v(this, "imageUri is not null. Handle shared image"); } else { AppLog.w(this, "imageUri is null. Cannot precede."); } Toast.makeText(this, "Not yet implemented.", Toast.LENGTH_SHORT).show(); }
From source file:com.example.angel.parkpanda.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 1003) { if (resultCode == Activity.RESULT_OK) { PaymentMethodNonce paymentMethodNonce = data .getParcelableExtra(BraintreePaymentActivity.EXTRA_PAYMENT_METHOD_NONCE); ///*from w w w. j a v a2 s .c o m*/ String nonce = paymentMethodNonce.getNonce(); postNonceToServer(nonce); // Send the nonce to your server. } } else if (requestCode == 2) { showGoogleSelectMarker(data); initViewSetting(true); } else if (requestCode == 35) { //showGoogleSelectMarker(data); initViewSetting(true); } }
From source file:com.lichen.teacher.apps.ActivityLive.java
private void getExtraData() { Intent intent = getIntent(); mLive = intent.getParcelableExtra(Constant.EXTRA_LIVE_INFO); }
From source file:com.owncloud.android.services.OperationsService.java
/** * Creates a new operation, as described by operationIntent. * /*from ww w . j a v a 2s . co m*/ * TODO - move to ServiceHandler (probably) * * @param operationIntent Intent describing a new operation to queue and execute. * @return Pair with the new operation object and the information about its * target server. */ private Pair<Target, RemoteOperation> newOperation(Intent operationIntent) { RemoteOperation operation = null; Target target = null; try { if (!operationIntent.hasExtra(EXTRA_ACCOUNT) && !operationIntent.hasExtra(EXTRA_SERVER_URL)) { Log_OC.e(TAG, "Not enough information provided in intent"); } else { Account account = operationIntent.getParcelableExtra(EXTRA_ACCOUNT); String serverUrl = operationIntent.getStringExtra(EXTRA_SERVER_URL); String cookie = operationIntent.getStringExtra(EXTRA_COOKIE); target = new Target(account, (serverUrl == null) ? null : Uri.parse(serverUrl), cookie); String action = operationIntent.getAction(); if (action.equals(ACTION_CREATE_SHARE_VIA_LINK)) { // Create public share via link String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH); if (remotePath != null && remotePath.length() > 0) { operation = new CreateShareViaLinkOperation(remotePath); String name = operationIntent.getStringExtra(EXTRA_SHARE_NAME); ((CreateShareViaLinkOperation) operation).setName(name); String password = operationIntent.getStringExtra(EXTRA_SHARE_PASSWORD); ((CreateShareViaLinkOperation) operation).setPassword(password); long expirationDateMillis = operationIntent .getLongExtra(EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS, 0); ((CreateShareViaLinkOperation) operation).setExpirationDateInMillis(expirationDateMillis); Boolean uploadToFolderPermission = operationIntent .getBooleanExtra(EXTRA_SHARE_PUBLIC_UPLOAD, false); ((CreateShareViaLinkOperation) operation).setPublicUpload(uploadToFolderPermission); int permissions = operationIntent.getIntExtra(EXTRA_SHARE_PERMISSIONS, OCShare.DEFAULT_PERMISSION); ((CreateShareViaLinkOperation) operation).setPermissions(permissions); } } else if (ACTION_UPDATE_SHARE_VIA_LINK.equals(action)) { long shareId = operationIntent.getLongExtra(EXTRA_SHARE_ID, -1); operation = new UpdateShareViaLinkOperation(shareId); String name = operationIntent.getStringExtra(EXTRA_SHARE_NAME); ((UpdateShareViaLinkOperation) operation).setName(name); String password = operationIntent.getStringExtra(EXTRA_SHARE_PASSWORD); ((UpdateShareViaLinkOperation) operation).setPassword(password); long expirationDate = operationIntent.getLongExtra(EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS, 0); ((UpdateShareViaLinkOperation) operation).setExpirationDate(expirationDate); if (operationIntent.hasExtra(EXTRA_SHARE_PUBLIC_UPLOAD)) { ((UpdateShareViaLinkOperation) operation) .setPublicUpload(operationIntent.getBooleanExtra(EXTRA_SHARE_PUBLIC_UPLOAD, false)); } if (operationIntent.hasExtra(EXTRA_SHARE_PERMISSIONS)) { ((UpdateShareViaLinkOperation) operation).setPermissions( operationIntent.getIntExtra(EXTRA_SHARE_PERMISSIONS, OCShare.DEFAULT_PERMISSION)); } } else if (ACTION_UPDATE_SHARE_WITH_SHAREE.equals(action)) { // Update private share, only permissions long shareId = operationIntent.getLongExtra(EXTRA_SHARE_ID, -1); operation = new UpdateSharePermissionsOperation(shareId); int permissions = operationIntent.getIntExtra(EXTRA_SHARE_PERMISSIONS, 1); ((UpdateSharePermissionsOperation) operation).setPermissions(permissions); } else if (action.equals(ACTION_CREATE_SHARE_WITH_SHAREE)) { // Create private share with user or group String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH); String shareeName = operationIntent.getStringExtra(EXTRA_SHARE_WITH); ShareType shareType = (ShareType) operationIntent.getSerializableExtra(EXTRA_SHARE_TYPE); int permissions = operationIntent.getIntExtra(EXTRA_SHARE_PERMISSIONS, -1); if (remotePath.length() > 0) { operation = new CreateShareWithShareeOperation(remotePath, shareeName, shareType, permissions); } } else if (action.equals(ACTION_UNSHARE)) { // Unshare file long shareId = operationIntent.getLongExtra(EXTRA_SHARE_ID, -1); operation = new RemoveShareOperation(shareId); } else if (action.equals(ACTION_GET_SERVER_INFO)) { // check OC server and get basic information from it operation = new GetServerInfoOperation(serverUrl, OperationsService.this); } else if (action.equals(ACTION_OAUTH2_GET_ACCESS_TOKEN)) { // CREATE ACCESS TOKEN to the OAuth server String code = operationIntent.getStringExtra(EXTRA_OAUTH2_AUTHORIZATION_CODE); OAuth2Provider oAuth2Provider = OAuth2ProvidersRegistry.getInstance().getProvider(); OAuth2RequestBuilder builder = oAuth2Provider.getOperationBuilder(); builder.setGrantType(OAuth2GrantType.AUTHORIZATION_CODE); builder.setRequest(OAuth2RequestBuilder.OAuthRequest.CREATE_ACCESS_TOKEN); builder.setAuthorizationCode(code); operation = builder.buildOperation(); } else if (action.equals(ACTION_GET_USER_NAME)) { // Get User Name operation = new GetRemoteUserInfoOperation(); } else if (action.equals(ACTION_RENAME)) { // Rename file or folder String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH); String newName = operationIntent.getStringExtra(EXTRA_NEWNAME); operation = new RenameFileOperation(remotePath, newName); } else if (action.equals(ACTION_REMOVE)) { // Remove file or folder String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH); boolean onlyLocalCopy = operationIntent.getBooleanExtra(EXTRA_REMOVE_ONLY_LOCAL, false); operation = new RemoveFileOperation(remotePath, onlyLocalCopy); } else if (action.equals(ACTION_CREATE_FOLDER)) { // Create Folder String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH); boolean createFullPath = operationIntent.getBooleanExtra(EXTRA_CREATE_FULL_PATH, true); operation = new CreateFolderOperation(remotePath, createFullPath); } else if (action.equals(ACTION_SYNC_FILE)) { // Sync file String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH); operation = new SynchronizeFileOperation(remotePath, account, getApplicationContext()); } else if (action.equals(ACTION_SYNC_FOLDER)) { // Sync folder (all its descendant files are sync'ed) String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH); boolean pushOnly = operationIntent.getBooleanExtra(EXTRA_PUSH_ONLY, false); boolean syncContentOfRegularFiles = operationIntent.getBooleanExtra(EXTRA_SYNC_REGULAR_FILES, false); operation = new SynchronizeFolderOperation(this, // TODO remove this dependency from construction time remotePath, account, System.currentTimeMillis(), // TODO remove this dependency from construction time pushOnly, false, syncContentOfRegularFiles); } else if (action.equals(ACTION_MOVE_FILE)) { // Move file/folder String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH); String newParentPath = operationIntent.getStringExtra(EXTRA_NEW_PARENT_PATH); operation = new MoveFileOperation(remotePath, newParentPath); } else if (action.equals(ACTION_COPY_FILE)) { // Copy file/folder String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH); String newParentPath = operationIntent.getStringExtra(EXTRA_NEW_PARENT_PATH); operation = new CopyFileOperation(remotePath, newParentPath, account); } else if (action.equals(ACTION_CHECK_CURRENT_CREDENTIALS)) { // Check validity of currently stored credentials for a given account operation = new CheckCurrentCredentialsOperation(account); } } } catch (IllegalArgumentException e) { Log_OC.e(TAG, "Bad information provided in intent: " + e.getMessage()); operation = null; } if (operation != null) { return new Pair<>(target, operation); } else { return null; } }
From source file:com.cerema.cloud2.files.services.FileUploader.java
/** * Entry point to add one or several files to the queue of uploads. * * New uploads are added calling to startService(), resulting in a call to * this method. This ensures the service will keep on working although the * caller activity goes away./* w w w . j av a 2 s. c om*/ */ @Override public int onStartCommand(Intent intent, int flags, int startId) { Log_OC.d(TAG, "Starting command with id " + startId); if (intent.hasExtra(KEY_CANCEL_ALL) && intent.hasExtra(KEY_ACCOUNT)) { Account account = intent.getParcelableExtra(KEY_ACCOUNT); if (mCurrentUpload != null) { FileUploaderBinder fub = (FileUploaderBinder) mBinder; fub.cancel(account); return Service.START_NOT_STICKY; } } if (!intent.hasExtra(KEY_ACCOUNT) || !intent.hasExtra(KEY_UPLOAD_TYPE) || !(intent.hasExtra(KEY_LOCAL_FILE) || intent.hasExtra(KEY_FILE))) { Log_OC.e(TAG, "Not enough information provided in intent"); return Service.START_NOT_STICKY; } int uploadType = intent.getIntExtra(KEY_UPLOAD_TYPE, -1); if (uploadType == -1) { Log_OC.e(TAG, "Incorrect upload type provided"); return Service.START_NOT_STICKY; } Account account = intent.getParcelableExtra(KEY_ACCOUNT); if (!AccountUtils.exists(account, getApplicationContext())) { return Service.START_NOT_STICKY; } String[] localPaths = null, remotePaths = null, mimeTypes = null; OCFile[] files = null; if (uploadType == UPLOAD_SINGLE_FILE) { if (intent.hasExtra(KEY_FILE)) { files = new OCFile[] { intent.getParcelableExtra(KEY_FILE) }; } else { localPaths = new String[] { intent.getStringExtra(KEY_LOCAL_FILE) }; remotePaths = new String[] { intent.getStringExtra(KEY_REMOTE_FILE) }; mimeTypes = new String[] { intent.getStringExtra(KEY_MIME_TYPE) }; } } else { // mUploadType == UPLOAD_MULTIPLE_FILES if (intent.hasExtra(KEY_FILE)) { files = (OCFile[]) intent.getParcelableArrayExtra(KEY_FILE); // TODO // will // this // casting // work // fine? } else { localPaths = intent.getStringArrayExtra(KEY_LOCAL_FILE); remotePaths = intent.getStringArrayExtra(KEY_REMOTE_FILE); mimeTypes = intent.getStringArrayExtra(KEY_MIME_TYPE); } } FileDataStorageManager storageManager = new FileDataStorageManager(account, getContentResolver()); boolean forceOverwrite = intent.getBooleanExtra(KEY_FORCE_OVERWRITE, false); boolean isInstant = intent.getBooleanExtra(KEY_INSTANT_UPLOAD, false); int localAction = intent.getIntExtra(KEY_LOCAL_BEHAVIOUR, LOCAL_BEHAVIOUR_FORGET); if (intent.hasExtra(KEY_FILE) && files == null) { Log_OC.e(TAG, "Incorrect array for OCFiles provided in upload intent"); return Service.START_NOT_STICKY; } else if (!intent.hasExtra(KEY_FILE)) { if (localPaths == null) { Log_OC.e(TAG, "Incorrect array for local paths provided in upload intent"); return Service.START_NOT_STICKY; } if (remotePaths == null) { Log_OC.e(TAG, "Incorrect array for remote paths provided in upload intent"); return Service.START_NOT_STICKY; } if (localPaths.length != remotePaths.length) { Log_OC.e(TAG, "Different number of remote paths and local paths!"); return Service.START_NOT_STICKY; } files = new OCFile[localPaths.length]; for (int i = 0; i < localPaths.length; i++) { files[i] = obtainNewOCFileToUpload(remotePaths[i], localPaths[i], ((mimeTypes != null) ? mimeTypes[i] : null)); if (files[i] == null) { // TODO @andomaex add failure Notification return Service.START_NOT_STICKY; } } } OwnCloudVersion ocv = AccountUtils.getServerVersion(account); boolean chunked = FileUploader.chunkedUploadIsSupported(ocv); AbstractList<String> requestedUploads = new Vector<String>(); String uploadKey = null; UploadFileOperation newUpload = null; try { for (int i = 0; i < files.length; i++) { newUpload = new UploadFileOperation(account, files[i], chunked, isInstant, forceOverwrite, localAction, getApplicationContext()); if (isInstant) { newUpload.setRemoteFolderToBeCreated(); } newUpload.addDatatransferProgressListener(this); newUpload.addDatatransferProgressListener((FileUploaderBinder) mBinder); Pair<String, String> putResult = mPendingUploads.putIfAbsent(account, files[i].getRemotePath(), newUpload); if (putResult != null) { uploadKey = putResult.first; requestedUploads.add(uploadKey); } // else, file already in the queue of uploads; don't repeat the request } } catch (IllegalArgumentException e) { Log_OC.e(TAG, "Not enough information provided in intent: " + e.getMessage()); return START_NOT_STICKY; } catch (IllegalStateException e) { Log_OC.e(TAG, "Bad information provided in intent: " + e.getMessage()); return START_NOT_STICKY; } catch (Exception e) { Log_OC.e(TAG, "Unexpected exception while processing upload intent", e); return START_NOT_STICKY; } if (requestedUploads.size() > 0) { Message msg = mServiceHandler.obtainMessage(); msg.arg1 = startId; msg.obj = requestedUploads; mServiceHandler.sendMessage(msg); } return Service.START_NOT_STICKY; }