List of usage examples for android.content Intent setPackage
public @NonNull Intent setPackage(@Nullable String packageName)
From source file:de.schildbach.wallet.WalletApplication.java
public void replaceWallet(final Wallet newWallet) { resetBlockchain();//w w w . j a v a 2s . c om wallet.shutdownAutosaveAndWait(); wallet = newWallet; config.maybeIncrementBestChainHeightEver(newWallet.getLastBlockSeenHeight()); afterLoadWallet(); final Intent broadcast = new Intent(ACTION_WALLET_REFERENCE_CHANGED); broadcast.setPackage(getPackageName()); LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast); }
From source file:io.nuclei.cyto.share.PackageTargetManager.java
/** * Create an intent with package specific modifications * * @param authority The file authority provider to be used for sharing files * @param permissionRequestCode Some packages may require we put files on external storage, * this is the permission request code that will be used to request that permission *//*from www . j av a 2 s.com*/ public Intent onCreateIntent(Activity activity, String authority, ResolveInfo info, int permissionRequestCode) { int maxLen = getMaxLen(info.activityInfo.packageName); String text = mText; if (maxLen != Integer.MAX_VALUE) text = trim(text, mUrl, maxLen); else if (mText != null && mUrl != null) text += '\n' + mUrl; Intent intent = new Intent(TextUtils.isEmpty(mEmail) ? Intent.ACTION_SEND : Intent.ACTION_SENDTO); intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name)); intent.setPackage(info.activityInfo.packageName); onSetDefault(activity, info.activityInfo.packageName, authority, intent, text); switch (info.activityInfo.packageName) { case FACEBOOK: intent = onFacebook(activity, intent); break; case WECHAT: intent = onExternalStorage(activity, intent, permissionRequestCode); break; case INSTAGRAM: if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) intent = onExternalStorage(activity, intent, permissionRequestCode); break; } return intent; }
From source file:biz.wiz.android.wallet.WalletApplication.java
public void resetBlockchain() { internalResetBlockchain();// w ww. j a va2s.c om final Intent broadcast = new Intent(ACTION_WALLET_CHANGED); broadcast.setPackage(getPackageName()); LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast); }
From source file:com.shopify.sample.activity.CheckoutActivity.java
private void launchBrowser(String url) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.setData(Uri.parse(url));//from ww w . j av a 2 s .c o m try { intent.setPackage("com.android.chrome"); startActivity(intent); } catch (Exception launchChromeException) { try { // Chrome could not be opened, attempt to us other launcher intent.setPackage(null); startActivity(intent); } catch (Exception launchOtherException) { onError(getString(R.string.checkout_error)); } } }
From source file:biz.wiz.android.wallet.WalletApplication.java
public void replaceWallet(final Wallet newWallet) { internalResetBlockchain(); // implicitly stops blockchain service wallet.shutdownAutosaveAndWait();//from ww w . j a v a2 s . c o m wallet = newWallet; config.maybeIncrementBestChainHeightEver(newWallet.getLastBlockSeenHeight()); afterLoadWallet(); final Intent broadcast = new Intent(ACTION_WALLET_CHANGED); broadcast.setPackage(getPackageName()); LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast); }
From source file:com.kanedias.vanilla.audiotag.PluginService.java
/** * Sends plugin info back to Vanilla Music service. * @param intent intent from player/*from w w w .ja v a2 s . c o m*/ */ private void handleRequestPluginParams(Intent intent) { Intent answer = new Intent(ACTION_HANDLE_PLUGIN_PARAMS); answer.setPackage(intent.getPackage()); answer.putExtra(EXTRA_PARAM_PLUGIN_NAME, getString(R.string.tag_editor)); answer.putExtra(EXTRA_PARAM_PLUGIN_APP, getApplicationInfo()); answer.putExtra(EXTRA_PARAM_PLUGIN_DESC, getString(R.string.plugin_desc)); sendBroadcast(answer); }
From source file:com.collecdoo.fragment.main.RegisterDriverPhotoFragment.java
private void openImageIntent(int uploadIndex) { //EasyImage.openChooserWithGallery(this,"Please choose",0); File imageFile = ImageHelper.createFile(context, "extend_picture.jpg"); String cameraImageFullPath = imageFile.getAbsolutePath(); cameraOutputFileUri = Uri.fromFile(imageFile); // Camera.//from w ww. j ava 2 s . c o m final List<Intent> cameraIntents = new ArrayList<Intent>(); final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); final PackageManager packageManager = context.getPackageManager(); final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0); for (ResolveInfo res : listCam) { final String packageName = res.activityInfo.packageName; final Intent intent = new Intent(captureIntent); intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); intent.setPackage(packageName); intent.putExtra(MediaStore.EXTRA_OUTPUT, cameraOutputFileUri); cameraIntents.add(intent); } // Filesystem. final Intent galleryIntent = new Intent(); galleryIntent.setType("image/*"); galleryIntent.setAction(Intent.ACTION_PICK); // Chooser of filesystem options. final Intent chooserIntent = Intent.createChooser(galleryIntent, "Select Source"); // Add the camera options. chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[] {})); startActivityForResult(chooserIntent, uploadIndex); }
From source file:com.kanedias.vanilla.lyrics.LyricsShowActivity.java
/** * Write to the song tag using Tag Editor Plugin *///from w w w. ja v a 2 s.co m private void writeToFileTag() { String lyrics = mLyricsText.getText().toString(); Intent request = new Intent(ACTION_LAUNCH_PLUGIN); request.setPackage(PLUGIN_TAG_EDIT_PKG); request.putExtra(EXTRA_PARAM_URI, (Uri) getIntent().getParcelableExtra(EXTRA_PARAM_URI)); request.putExtra(EXTRA_PARAM_PLUGIN_APP, getApplicationInfo()); request.putExtra(EXTRA_PARAM_P2P, P2P_WRITE_TAG); request.putExtra(EXTRA_PARAM_P2P_KEY, new String[] { "LYRICS" }); // tag name request.putExtra(EXTRA_PARAM_P2P_VAL, new String[] { lyrics }); // tag value startActivity(request); }
From source file:me.trashout.fragment.EventDetailFragment.java
@OnClick({ R.id.event_detail_join_btn, R.id.event_detail_phone_layout, R.id.event_detail_email_layout, R.id.event_detail_direction_btn }) public void onClick(View view) { switch (view.getId()) { case R.id.event_detail_join_btn: if (mEvent != null) { if (user == null) { showToast(R.string.event_signToJoin); } else { MaterialDialog dialog = new MaterialDialog.Builder(getActivity()) .title(R.string.global_validation_warning) .content(R.string.event_joinEventConfirmationMessage).positiveText(android.R.string.ok) .negativeText(android.R.string.cancel).autoDismiss(true) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { showProgressDialog(); JoinUserToEventService.startForRequest(getContext(), JOIN_TO_EVENT_REQUEST_ID, mEvent.getId(), Collections.singletonList(user.getId())); }/*from w w w . j av a 2 s. co m*/ }).build(); dialog.show(); } } break; case R.id.event_detail_phone_layout: if (mEvent != null && mEvent.getContact() != null && !TextUtils.isEmpty(mEvent.getContact().getPhone())) { Intent intent = new Intent(Intent.ACTION_DIAL, Uri.fromParts("tel", mEvent.getContact().getPhone(), null)); startActivity(intent); } break; case R.id.event_detail_email_layout: if (mEvent != null && mEvent.getContact() != null && !TextUtils.isEmpty(mEvent.getContact().getEmail())) { sendEmail(); } break; case R.id.event_detail_direction_btn: if (mEvent != null) { Uri gmmIntentUri = Uri.parse("http://maps.google.com/maps?daddr=" + mEvent.getGps().getLat() + "," + mEvent.getGps().getLng()); Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); mapIntent.setPackage("com.google.android.apps.maps"); if (mapIntent.resolveActivity(getActivity().getPackageManager()) != null) { startActivity(mapIntent); } } break; } }
From source file:com.android.nfc.beam.BeamTransferManager.java
void whitelistOppDevice(BluetoothDevice device) { if (DBG)//from w ww .j av a 2 s . c om Log.d(TAG, "Whitelisting " + device + " for BT OPP"); Intent intent = new Intent(ACTION_WHITELIST_DEVICE); intent.setPackage(BLUETOOTH_PACKAGE); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT); }