List of usage examples for android.content Intent setDataAndType
public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type)
From source file:butter.droid.activities.base.ButterBaseActivity.java
@Override protected void onCreate(Bundle savedInstanceState, int layoutId) { super.onCreate(savedInstanceState, layoutId); if (!VersionUtils.isUsingCorrectBuild()) { new AlertDialog.Builder(this).setMessage(butter.droid.base.R.string.wrong_abi).setCancelable(false) .show();/*from w w w . j a v a 2 s .c o m*/ ButterUpdater.getInstance(this, new ButterUpdater.Listener() { @Override public void updateAvailable(String updateFile) { Intent installIntent = new Intent(Intent.ACTION_VIEW); installIntent.setDataAndType(Uri.parse("file://" + updateFile), ButterUpdater.ANDROID_PACKAGE); installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(installIntent); } }).checkUpdatesManually(); } }
From source file:com.commonsware.android.okhttp3.progress.Downloader.java
private void raiseNotification(String contentType, File output, Exception e) { NotificationCompat.Builder b = new NotificationCompat.Builder(this); b.setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL).setWhen(System.currentTimeMillis()); if (e == null) { b.setContentTitle(getString(R.string.download_complete)).setContentText(getString(R.string.fun)) .setSmallIcon(android.R.drawable.stat_sys_download_done) .setTicker(getString(R.string.download_complete)); Intent outbound = new Intent(Intent.ACTION_VIEW); outbound.setDataAndType(Uri.fromFile(output), contentType); b.setContentIntent(PendingIntent.getActivity(this, 0, outbound, 0)); } else {//from w w w .j a v a 2 s . co m b.setContentTitle(getString(R.string.exception)).setContentText(e.getMessage()) .setSmallIcon(android.R.drawable.stat_notify_error).setTicker(getString(R.string.exception)); } mgr.notify(NOTIFY_ID, b.build()); }
From source file:com.android.settings.SettingsLicenseActivity.java
private void showHtmlFromUri(Uri uri) { // Kick off external viewer due to WebView security restrictions; we // carefully point it at HTMLViewer, since it offers to decompress // before viewing. final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "text/html"); intent.putExtra(Intent.EXTRA_TITLE, getString(R.string.settings_license_activity_title)); if (ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) { intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); }// w w w . j a v a2 s . co m intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setPackage("com.android.htmlviewer"); try { startActivity(intent); finish(); } catch (ActivityNotFoundException e) { Log.e(TAG, "Failed to find viewer", e); showErrorAndFinish(); } }
From source file:com.google.android.demos.jamendo.app.PlaylistActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); int groupId = MENU_GROUP_INTENT_OPTIONS; int itemId = Menu.NONE; int order = Menu.NONE; ComponentName caller = getComponentName(); Intent[] specifics = null;/* w w w. j a v a 2s . co m*/ Intent intent = new Intent(); long id = ContentUris.parseId(getIntent().getData()); intent.setDataAndType(JamendoContract.createPlaylistUri(JamendoContract.FORMAT_M3U, Playlists.ID, id), JamendoContract.CONTENT_TYPE_M3U); intent.addCategory(Intent.CATEGORY_ALTERNATIVE); int flags = 0; MenuItem[] outSpecificItems = null; menu.addIntentOptions(groupId, itemId, order, caller, specifics, intent, flags, outSpecificItems); return menu.hasVisibleItems(); }
From source file:me.xingrz.finder.EntriesActivity.java
protected Intent intentToView(Uri uri, String mime) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, mime); intent.addCategory(Intent.CATEGORY_DEFAULT); for (ResolveInfo resolved : getPackageManager().queryIntentActivities(intent, 0)) { if (BuildConfig.APPLICATION_ID.equals(resolved.activityInfo.packageName)) { intent.setClassName(this, resolved.activityInfo.name); intent.putExtra(EXTRA_ALLOW_BACK, true); }/*from w w w . j a va 2s . co m*/ } return intent; }
From source file:com.dd.courier.fragment.RegistFragmentSecond.java
public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); switch (v.getId()) { case R.id.tv_card_front: startActivityForResult(intent, MyConstants.PHOTO_CDRD_FRONT_DATA); break;// w w w . java 2 s . com case R.id.tv_card_rear: startActivityForResult(intent, MyConstants.PHOTO_CDRD_REAR_DATA); break; case R.id.tv_card: startActivityForResult(intent, MyConstants.PHOTO_CDRD_WITH_DATA); break; default: break; } }
From source file:com.f2prateek.dfg.core.GenerateFrameService.java
@Override public void doneImage(final Uri imageUri) { Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override/*from ww w. j av a 2s . com*/ public void run() { bus.post(new Events.SingleImageProcessed(device, imageUri)); } }); // Create the intent to let the user share the image Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("image/png"); sharingIntent.putExtra(Intent.EXTRA_STREAM, imageUri); Intent chooserIntent = Intent.createChooser(sharingIntent, null); chooserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); notificationBuilder.addAction(R.drawable.ic_action_share, getResources().getString(R.string.share), PendingIntent.getActivity(this, 0, chooserIntent, PendingIntent.FLAG_CANCEL_CURRENT)); // Create the intent to let the user rate the app Intent rateIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(AppConstants.MARKET_URL)); notificationBuilder.addAction(R.drawable.ic_action_rate, getResources().getString(R.string.rate), PendingIntent.getActivity(this, 0, rateIntent, PendingIntent.FLAG_CANCEL_CURRENT)); // Create the intent to show the screenshot in gallery Intent launchIntent = new Intent(Intent.ACTION_VIEW); launchIntent.setDataAndType(imageUri, "image/png"); launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); notificationBuilder.setContentTitle(resources.getString(R.string.screenshot_saved_title)) .setContentText(resources.getString(R.string.single_screenshot_saved, device.name())) .setContentIntent(PendingIntent.getActivity(this, 0, launchIntent, 0)) .setWhen(System.currentTimeMillis()).setProgress(0, 0, false).setAutoCancel(true); notificationManager.notify(DFG_NOTIFICATION_ID, notificationBuilder.build()); }
From source file:com.joeyturczak.jtscanner.ui.FileListFragment.java
private void openFile(final int position) { File externalDir = Environment.getExternalStorageDirectory(); String externalDirPath = externalDir.getPath(); final File scannerDir = new File(externalDirPath + getString(R.string.file_directory)); File file = new File(scannerDir + File.separator + mFileNames.get(position)); final Uri path = Uri.fromFile(file); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(path, getString(R.string.excel_data_type)); try {/* ww w . ja va 2 s . c om*/ startActivity(intent); } catch (Exception e) { if (mToast != null) { mToast.cancel(); } mToast = Toast.makeText(getActivity(), R.string.toast_no_app_found, Toast.LENGTH_SHORT); mToast.show(); } }
From source file:com.magizdev.babyoneday.profilewizard.AvatarFragment.java
public void resizeImage(Uri uri) { Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(uri, "image/*"); intent.putExtra("crop", "true"); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("outputX", 450); intent.putExtra("outputY", 450); intent.putExtra("return-data", true); startActivityForResult(intent, RESIZE_REQUEST_CODE); }
From source file:com.digigene.autoupdate.presenter.DownloadDialogPresenterImpl.java
private void doWhenDownloadIsFinishedInForcedMode(String fileName) { File directory = context.getExternalFilesDir(null); File file = new File(directory, fileName); Uri fileUri = Uri.fromFile(file);//from w ww .jav a 2 s . co m if (Build.VERSION.SDK_INT >= 24) { fileUri = FileProvider.getUriForFile(context, context.getPackageName(), file); } Intent intent = new Intent(Intent.ACTION_VIEW, fileUri); intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true); intent.setDataAndType(fileUri, "application/vnd.android" + ".package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); context.startActivity(intent); activity.finish(); }