List of usage examples for android.content Intent setData
public @NonNull Intent setData(@Nullable Uri data)
From source file:cordova.plugins.Diagnostic.java
public void switchToAppSettings() { Log.d(TAG, "Switch to App Settings"); Intent appIntent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", cordova.getActivity().getPackageName(), null); appIntent.setData(uri); cordova.getActivity().startActivity(appIntent); }
From source file:com.pursuer.reader.easyrss.VerticalSingleItemView.java
private void updateButtonOpenLink() { final View btnOpenLink = menu.findViewById(R.id.BtnOpenLink); btnOpenLink.setOnClickListener(new OnClickListener() { @Override//from w ww . j a v a 2 s . c o m public void onClick(final View view) { if (listener != null) { final SettingBrowserChoice setting = new SettingBrowserChoice(dataMgr); switch (setting.getData()) { case SettingBrowserChoice.BROWSER_CHOICE_UNKNOWN: final LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final AlertDialog.Builder builder = new AlertDialog.Builder( new ContextThemeWrapper(context, android.R.style.Theme_DeviceDefault_Dialog)); final View popupView = inflater.inflate(R.layout.browser_choice_popup, null); final CheckBox checkBox = (CheckBox) popupView.findViewById(R.id.CheckBoxDontShowAgain); checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { popupView.findViewById(R.id.Hint).setVisibility(View.VISIBLE); } }); final String items[] = new String[3]; items[0] = context.getString(R.string.TxtBuiltInMobilized); items[1] = context.getString(R.string.TxtBuiltInOriginal); items[2] = context.getString(R.string.TxtExternalOriginal); builder.setTitle(R.string.TxtChooseBrowser); builder.setView(popupView); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { switch (which) { case 0: if (listener != null) { listener.showWebsitePage(item.getUid(), true); } if (checkBox.isChecked()) { setting.setData(dataMgr, SettingBrowserChoice.BROWSER_CHOICE_MOBILIZED); } dialog.dismiss(); break; case 1: if (listener != null) { listener.showWebsitePage(item.getUid(), false); } if (checkBox.isChecked()) { setting.setData(dataMgr, SettingBrowserChoice.BROWSER_CHOICE_ORIGINAL); } dialog.dismiss(); break; case 2: final Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(item.getHref())); context.startActivity(intent); if (checkBox.isChecked()) { setting.setData(dataMgr, SettingBrowserChoice.BROWSER_CHOICE_EXTERNAL); } dialog.dismiss(); break; default: break; } } }); builder.setNegativeButton(context.getString(R.string.TxtCancel), new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int which) { dialog.dismiss(); } }); builder.show(); break; case SettingBrowserChoice.BROWSER_CHOICE_EXTERNAL: final Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(item.getHref())); context.startActivity(intent); break; case SettingBrowserChoice.BROWSER_CHOICE_MOBILIZED: if (listener != null) { listener.showWebsitePage(item.getUid(), true); } break; case SettingBrowserChoice.BROWSER_CHOICE_ORIGINAL: if (listener != null) { listener.showWebsitePage(item.getUid(), false); } break; default: break; } } } }); }
From source file:com.android.providers.downloads.DownloadInfo.java
void notifyPauseDueToSize(boolean isWifiRequired) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(getAllDownloadsUri()); intent.setClassName(SizeLimitActivity.class.getPackage().getName(), SizeLimitActivity.class.getName()); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(EXTRA_IS_WIFI_REQUIRED, isWifiRequired); /// M: Modify to support CU customization intent.putExtra(SHOW_DIALOG_REASON, 0); mContext.startActivity(intent);//from w ww . j av a 2 s . c o m }
From source file:com.oonhee.oojs.inappbrowser.InAppBrowser.java
/** * Display a new browser with the specified URL. * * @param url The url to load. * @param usePhoneGap Load url in PhoneGap webview * @return "" if ok, or error message. *//*from w w w . j ava 2s . c om*/ public String openExternal(String url) { try { Intent intent = null; intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); this.cordova.getActivity().startActivity(intent); return ""; } catch (android.content.ActivityNotFoundException e) { Log.d(LOG_TAG, "InAppBrowser: Error loading url " + url + ":" + e.toString()); return e.toString(); } }
From source file:com.hackensack.umc.activity.ProfileSelfieActivityCustomeCam.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case Constant.FRAGMENT_CONST_REQUEST_IMAGE_CAPTURE: if (resultCode == RESULT_OK) { Intent intent = new Intent(ProfileSelfieActivityCustomeCam.this, ActivityCropImage.class); intent.setData(imageUri); startActivityForResult(intent, Constant.CROP_IMAGE_ACTIVITY); }/*from ww w . j a v a 2 s . co m*/ break; case Constant.CROP_IMAGE_ACTIVITY: if (resultCode == RESULT_OK) { try { if (data != null) { imageUri = data.getData(); CameraFunctionality.setPhotoToImageView(imageUri.toString(), imgSelfie, ProfileSelfieActivityCustomeCam.this); getImageUris(imageUri, 5); txtSefileSet.setText(R.string.done); } } catch (Exception e) { e.printStackTrace(); } } break; } }
From source file:com.amazonaws.mobileconnectors.pinpoint.targeting.notification.NotificationClient.java
private void openURL(final String url, final boolean noSchemeValidation) { final String validatedUrl; if (url.startsWith("http://") || url.startsWith("https://") || noSchemeValidation) { validatedUrl = url;//w w w . j a va 2s .c om } else { validatedUrl = "http://" + url; } final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(validatedUrl)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (intent.resolveActivity(pinpointContext.getApplicationContext().getPackageManager()) != null) { pinpointContext.getApplicationContext().startActivity(intent); } }
From source file:com.olearyp.gusto.Expsetup.java
protected void sendCommand(final String command, final String description, final String state) { final Intent runCmd = new Intent("com.olearyp.gusto.SUEXEC"); runCmd.setData( Uri.fromParts("command", ". /system/bin/exp_script.sh.lib && read_in_ep_config && " + command, "")) .putExtra("com.olearyp.gusto.STATE", state); final Notification note = new Notification(R.drawable.icon, description.substring(0, 1).toUpperCase() + description.substring(1) + "...", System.currentTimeMillis()); note.setLatestEventInfo(Expsetup.this, getString(R.string.app_name), getString(R.string.app_name) + " is " + description + "...", PendingIntent.getBroadcast(Expsetup.this, 0, null, 0)); runCmd.putExtra("com.olearyp.gusto.RUN_NOTIFICATION", note); startService(runCmd);//from w w w . j a va 2s .co m setServerState(state); if (getServerState().equals(getString(R.string.reboot_manual_flash_required))) { final Intent intent = new Intent("com.olearyp.gusto.SUEXEC") .setData(Uri.fromParts("commandid", Integer.toString(R.string.reboot_recovery), "")); final PendingIntent contentIntent = PendingIntent.getService(this, 0, intent, 0); final Notification rebootNote = new Notification(R.drawable.status_reboot, getString(R.string.reboot_recovery_required_msg), System.currentTimeMillis()); rebootNote.setLatestEventInfo(this, "GUSTO reboot request", getString(R.string.reboot_recovery_doit_msg), contentIntent); rebootNote.deleteIntent = PendingIntent.getBroadcast(this, 0, new Intent("com.olearyp.gusto.RESET_SERVER_STATE"), 0); rebootNote.flags |= Notification.FLAG_SHOW_LIGHTS; rebootNote.ledOnMS = 200; rebootNote.ledOffMS = 400; rebootNote.ledARGB = Color.argb(255, 255, 0, 0); nm.notify(REBOOT_NOTIFICATION, rebootNote); } else if (getServerState().equals(getString(R.string.reboot_recovery_required))) { final Intent intent = new Intent("com.olearyp.gusto.SUEXEC") .setData(Uri.fromParts("commandid", Integer.toString(R.string.reboot), "")); final PendingIntent contentIntent = PendingIntent.getService(this, 0, intent, 0); final Notification rebootNote = new Notification(R.drawable.status_reboot, getString(R.string.reboot_autoflash_required_msg), System.currentTimeMillis()); rebootNote.setLatestEventInfo(this, "GUSTO reboot request", getString(R.string.reboot_autoflash_doit_msg), contentIntent); rebootNote.deleteIntent = PendingIntent.getBroadcast(this, 0, new Intent("com.olearyp.gusto.RESET_SERVER_STATE"), 0); rebootNote.flags |= Notification.FLAG_SHOW_LIGHTS; rebootNote.ledOnMS = 200; rebootNote.ledOffMS = 600; rebootNote.ledARGB = Color.argb(255, 255, 255, 0); nm.notify(REBOOT_NOTIFICATION, rebootNote); } else if (getServerState().equals(getString(R.string.reboot_required))) { final Intent intent = new Intent("com.olearyp.gusto.SUEXEC") .setData(Uri.fromParts("commandid", Integer.toString(R.string.reboot), "")); final PendingIntent contentIntent = PendingIntent.getService(this, 0, intent, 0); final Notification rebootNote = new Notification(R.drawable.status_reboot, getString(R.string.reboot_required_msg), System.currentTimeMillis()); rebootNote.setLatestEventInfo(this, "GUSTO reboot request", getString(R.string.reboot_doit_msg), contentIntent); rebootNote.deleteIntent = PendingIntent.getBroadcast(this, 0, new Intent("com.olearyp.gusto.RESET_SERVER_STATE"), 0); rebootNote.flags |= Notification.FLAG_SHOW_LIGHTS; rebootNote.ledOnMS = 200; rebootNote.ledOffMS = 600; rebootNote.ledARGB = Color.argb(255, 255, 255, 0); nm.notify(REBOOT_NOTIFICATION, rebootNote); } }
From source file:name.gumartinm.weather.information.widget.WidgetIntentService.java
private RemoteViews makeView(final Current current, final WeatherLocation weatherLocation, final int appWidgetId) { // 1. Update units of measurement. UnitsConversor tempUnitsConversor;//w ww . j a v a 2s.c om String keyPreference = this.getApplicationContext() .getString(R.string.widget_preferences_temperature_units_key); String realKeyPreference = keyPreference + "_" + appWidgetId; // What was saved to permanent storage (or default values if it is the first time) final int tempValue = this.getSharedPreferences(WIDGET_PREFERENCES_NAME, Context.MODE_PRIVATE) .getInt(realKeyPreference, 0); final String tempSymbol = this.getResources() .getStringArray(R.array.weather_preferences_temperature)[tempValue]; if (tempValue == 0) { tempUnitsConversor = new UnitsConversor() { @Override public double doConversion(final double value) { return value - 273.15; } }; } else if (tempValue == 1) { tempUnitsConversor = new UnitsConversor() { @Override public double doConversion(final double value) { return (value * 1.8) - 459.67; } }; } else { tempUnitsConversor = new UnitsConversor() { @Override public double doConversion(final double value) { return value; } }; } // 2. Update country. keyPreference = this.getApplicationContext().getString(R.string.widget_preferences_country_switch_key); realKeyPreference = keyPreference + "_" + appWidgetId; // What was saved to permanent storage (or default values if it is the first time) final boolean isCountry = this.getSharedPreferences(WIDGET_PREFERENCES_NAME, Context.MODE_PRIVATE) .getBoolean(realKeyPreference, false); // 3. Formatters final DecimalFormat tempFormatter = (DecimalFormat) NumberFormat.getNumberInstance(Locale.US); tempFormatter.applyPattern("###.##"); // 4. Prepare data for RemoteViews. String tempMax = ""; if (current.getMain().getTemp_max() != null) { double conversion = (Double) current.getMain().getTemp_max(); conversion = tempUnitsConversor.doConversion(conversion); tempMax = tempFormatter.format(conversion) + tempSymbol; } String tempMin = ""; if (current.getMain().getTemp_min() != null) { double conversion = (Double) current.getMain().getTemp_min(); conversion = tempUnitsConversor.doConversion(conversion); tempMin = tempFormatter.format(conversion) + tempSymbol; } Bitmap picture; if ((current.getWeather().size() > 0) && (current.getWeather().get(0).getIcon() != null) && (IconsList.getIcon(current.getWeather().get(0).getIcon()) != null)) { final String icon = current.getWeather().get(0).getIcon(); picture = BitmapFactory.decodeResource(this.getResources(), IconsList.getIcon(icon).getResourceDrawable()); } else { picture = BitmapFactory.decodeResource(this.getResources(), R.drawable.weather_severe_alert); } final String city = weatherLocation.getCity(); final String country = weatherLocation.getCountry(); // 5. Insert data in RemoteViews. final RemoteViews remoteView = new RemoteViews(this.getApplicationContext().getPackageName(), R.layout.appwidget); remoteView.setImageViewBitmap(R.id.weather_appwidget_image, picture); remoteView.setTextViewText(R.id.weather_appwidget_temperature_max, tempMax); remoteView.setTextViewText(R.id.weather_appwidget_temperature_min, tempMin); remoteView.setTextViewText(R.id.weather_appwidget_city, city); if (!isCountry) { remoteView.setViewVisibility(R.id.weather_appwidget_country, View.GONE); } else { // TODO: It is as if Android had a view cache. If I did not set VISIBLE value, // the country field would be gone forever... :/ remoteView.setViewVisibility(R.id.weather_appwidget_country, View.VISIBLE); remoteView.setTextViewText(R.id.weather_appwidget_country, country); } // 6. Activity launcher. final Intent resultIntent = new Intent(this.getApplicationContext(), WidgetConfigure.class); resultIntent.putExtra("actionFromUser", true); resultIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); // From: http://stackoverflow.com/questions/4011178/multiple-instances-of-widget-only-updating-last-widget final Uri data = Uri.withAppendedPath(Uri.parse("PAIN" + "://widget/id/"), String.valueOf(appWidgetId)); resultIntent.setData(data); final TaskStackBuilder stackBuilder = TaskStackBuilder.create(this.getApplicationContext()); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(WidgetConfigure.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); final PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); remoteView.setOnClickPendingIntent(R.id.weather_appwidget, resultPendingIntent); return remoteView; }