List of usage examples for android.content Intent setData
public @NonNull Intent setData(@Nullable Uri data)
From source file:com.googlecode.android_scripting.rpc.MethodDescriptor.java
public static Object buildIntent(JSONObject jsonObject) throws JSONException { Intent intent = new Intent(); if (jsonObject.has("action")) { intent.setAction(jsonObject.getString("action")); }// www. ja v a 2 s . c om if (jsonObject.has("data") && jsonObject.has("type")) { intent.setDataAndType(Uri.parse(jsonObject.optString("data", null)), jsonObject.optString("type", null)); } else if (jsonObject.has("data")) { intent.setData(Uri.parse(jsonObject.optString("data", null))); } else if (jsonObject.has("type")) { intent.setType(jsonObject.optString("type", null)); } if (jsonObject.has("packagename") && jsonObject.has("classname")) { intent.setClassName(jsonObject.getString("packagename"), jsonObject.getString("classname")); } if (jsonObject.has("flags")) { intent.setFlags(jsonObject.getInt("flags")); } if (!jsonObject.isNull("extras")) { AndroidFacade.putExtrasFromJsonObject(jsonObject.getJSONObject("extras"), intent); } if (!jsonObject.isNull("categories")) { JSONArray categories = jsonObject.getJSONArray("categories"); for (int i = 0; i < categories.length(); i++) { intent.addCategory(categories.getString(i)); } } return intent; }
From source file:info.papdt.blacklight.support.Utility.java
public static void notifyScanPhotos(Context context, String path) { Intent i = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); Uri uri = Uri.fromFile(new File(path)); i.setData(uri); context.sendBroadcast(i);// ww w.java2 s . com }
From source file:com.samsung.richnotification.RichNotificationHelper.java
public static List<SrnAction> createActions(Context mContext, CallbackContext callbackContext, RichNotificationOptions options) throws JSONException { ArrayList<SrnAction> actionsList = new ArrayList<SrnAction>(); JSONArray actions = options.actions; if (actions == null) return null; SrnAction action = null;//www .java2 s . c o m for (int i = 0; i < actions.length(); i++) { JSONObject act = actions.optJSONObject(i); if (act == null) continue; String actionLabel = act.optString("actionLabel", EMPTY_STRING); if (actionLabel.isEmpty()) continue; Bitmap actionIcon = getIconBitmap(mContext, "file://" + act.optString("actionIcon")); SrnImageAsset actionImg = new SrnImageAsset(mContext, actionLabel, actionIcon); int actionType = act.optInt("type"); switch (actionType) { case ACTION_TYPE_CALL: SrnRemoteBuiltInAction call = new SrnRemoteBuiltInAction(actionLabel, OperationType.CALL); call.setData(Uri.parse(act.optString("dest"))); action = call; break; case ACTION_TYPE_SMS: SrnRemoteBuiltInAction sms = new SrnRemoteBuiltInAction(actionLabel, OperationType.SMS); sms.setData(Uri.fromParts("sms", act.optString("dest"), null)); action = sms; break; case ACTION_TYPE_EMAIL: Log.d(TAG, "Email to: '" + act.optString("dest") + "'"); Log.d(TAG, "Subject: '" + act.optString("subject") + "'"); Log.d(TAG, "Body: '" + act.optString("body") + "'"); SrnHostAction email = new SrnHostAction(actionLabel); Intent emailIntent = new Intent(Intent.ACTION_SENDTO); String uriText = "mailto:" + act.optString("dest") + "?subject=" + Uri.encode(act.optString("subject")) + "&body=" + Uri.encode(act.optString("body")); Uri uri = Uri.parse(uriText); emailIntent.setData(uri); email.setCallbackIntent(CallbackIntent.getActivityCallback(emailIntent)); email.setToast(act.optString("toast")); email.setIcon(actionImg); action = email; break; case ACTION_TYPE_VIEW: SrnHostAction view = new SrnHostAction(actionLabel); Intent viewIntent = new Intent(Intent.ACTION_VIEW); String urlText = act.optString("dest"); Uri url = Uri.parse(urlText); viewIntent.setData(url); view.setCallbackIntent(CallbackIntent.getActivityCallback(viewIntent)); view.setToast(act.optString("toast")); view.setIcon(actionImg); action = view; break; case ACTION_TYPE_INPUT_KEYBOARD: case ACTION_TYPE_INPUT_SINGLE_SELECT: case ACTION_TYPE_INPUT_MULTI_SELECT: SrnRemoteInputAction input = getRemoteInputAction(mContext, act); if (input == null) { continue; } Intent inputIntent = new Intent("com.samsung.cordova.richnotification.remote_input_receiver"); inputIntent.putExtra("callbackID", callbackContext.getCallbackId()); String actionID = act.optString("actionID", EMPTY_STRING); if (actionID.isEmpty()) { continue; } else { inputIntent.putExtra("actionID", actionID); } input.setCallbackIntent(CallbackIntent.getBroadcastCallback(inputIntent)); input.setIcon(actionImg); action = input; break; default: Log.e(TAG, "Invalid action type: " + actionType); continue; } Log.d(TAG, "Action type created: " + actionType); actionsList.add(action); } return actionsList; }
From source file:edu.polyu.screamalert.SoundProcessing.java
private static void callPhone() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Exchanger.thisContext); String phoneNumber = prefs.getString("phoneNumber", null); Boolean enableCall = prefs.getBoolean("enableCall", false); if (phoneNumber != null && enableCall) { if (phoneNumber.trim().length() > 0) { // Avoid empty string or white spaces in the preference field TelephonyManager phoneMgr = (TelephonyManager) thisContext .getSystemService(Context.TELEPHONY_SERVICE); if (phoneMgr.getCallState() == TelephonyManager.CALL_STATE_IDLE && phoneMgr.getSimState() != TelephonyManager.SIM_STATE_ABSENT) { Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); callIntent.setData(Uri.parse("tel:" + phoneNumber)); Exchanger.thisContext.startActivity(callIntent); }/*from ww w .j a va 2 s . c o m*/ } } }
From source file:com.farmerbb.secondscreen.util.U.java
public static void checkForUpdates(Context context) { // If Google Play Store is installed, direct the user to the Play Store page for SecondScreen. // Otherwise, direct them to the Downloads page on the xda thread. String url;//from w w w . j a v a 2s .com try { context.getPackageManager().getPackageInfo("com.android.vending", 0); url = "https://play.google.com/store/apps/details?id=" + context.getPackageName(); } catch (PackageManager.NameNotFoundException e) { url = "http://forum.xda-developers.com/devdb/project/?id=5032#downloads"; } Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
From source file:MainActivity.java
public void dialPhone(View view) { if (checkPermission("android.permission.CALL_PHONE")) { Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:0123456789")); startActivity(intent);//from w w w . j a va2 s .co m } }
From source file:MainActivity.java
public void launchIntent(View view) { Log.i("MainActivity", "launchIntent()"); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("https://www.java2s.com/")); startActivity(intent);//from www . j ava 2 s .c om }
From source file:MainActivity.java
public void dialPhone(View view) { if (checkCallPermission()) { Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:0123456789")); startActivity(intent);// www .j a v a 2 s . c o m } }
From source file:com.phonegap.plugins.ExternalAppLauncher.ExternalAppLauncher.java
/** * launch market to certain app// w w w . ja va 2 s . c om */ private boolean launchMarket(Context context, String packageName) { Log.d(pluginName, "Launch Market"); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=" + packageName)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Boolean result = false; try { context.startActivity(intent); result = true; } catch (Exception ex) { Log.d(pluginName, ex.getMessage()); result = false; } return result; }
From source file:com.beesham.popularmovies.ReviewAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { final DetailsFragment.Reviews reviews = getItem(position); if (convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_item_review, parent, false); }//from w w w . jav a 2 s . c o m ButterKnife.bind(this, convertView); reviewAuthorTextView.setText(reviews.getAuthor()); readReviewButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(reviews.getUrl())); if (intent.resolveActivity(getContext().getPackageManager()) != null) { getContext().startActivity(intent); } } }); return convertView; }