List of usage examples for android.net Uri parse
public static Uri parse(String uriString)
From source file:Main.java
public static void addToCalendar(Activity context, Long beginTime, String title) { ContentResolver cr = context.getContentResolver(); Uri.Builder builder = Uri.parse("content://com.android.calendar/instances/when").buildUpon(); Long time = new Date(beginTime).getTime(); ContentUris.appendId(builder, time - 10 * 60 * 1000); ContentUris.appendId(builder, time + 10 * 60 * 1000); String[] projection = new String[] { "title", "begin" }; Cursor cursor = cr.query(builder.build(), projection, null, null, null); boolean exists = false; if (cursor != null) { while (cursor.moveToNext()) { if ((time == cursor.getLong(1)) && title.equals(cursor.getString(0))) { exists = true;//from ww w. j a v a 2 s.co m } } } if (!exists) { Intent intent = new Intent(Intent.ACTION_EDIT); intent.setType("vnd.android.cursor.item/event"); intent.putExtra("beginTime", time); intent.putExtra("allDay", false); intent.putExtra("endTime", time + 60 * 60 * 1000); intent.putExtra("title", title); context.startActivity(intent); } else { Toast.makeText(context, "Event already exist!", Toast.LENGTH_LONG).show(); } }
From source file:Main.java
/** * @brief Get the intent to invoke sending email. * * @par Sync (or) Async://from ww w . j av a 2 s . c o m * This is a Synchronous function. * * @param [IN] email Email address.\n * * @return * * @author daiping.zhao * @since 1.0.0.0 * @version 1.0.0.0 * @par Prospective Clients: * External Classes */ public static Intent doEmail(String email) { Uri uri = Uri.parse("mailto:" + email); return new Intent(Intent.ACTION_SENDTO, uri); }
From source file:Main.java
/** * Shortcut intent for icon on home screen. * @param url Url of the shortcut.//from w ww .j av a 2 s.c om * @return Intent for onclick action of the shortcut. */ public static Intent createShortcutIntent(String url) { Intent shortcutIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); shortcutIntent.putExtra(REUSE_URL_MATCHING_TAB_ELSE_NEW_TAB, true); return shortcutIntent; }
From source file:Main.java
/** * @brief Get the intent to make a call. * * @par Sync (or) Async:// www .j a v a 2s .co m * This is a Synchronous function. * * @param [IN] telNumber Telephone number.\n * * @return * * @author daiping.zhao * @since 1.0.0.0 * @version 1.0.0.0 * @par Prospective Clients: * External Classes */ public static Intent doCall(String telNumber) { Uri uri = Uri.parse("tel:" + telNumber); Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(uri); return intent; }
From source file:Main.java
public static Uri getImageUri(Context inContext, Bitmap inImage) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes); String path = MediaStore.Images.Media.insertImage(inContext.getContentResolver(), inImage, "croppedImage", null);/*from ww w.jav a2 s.co m*/ return Uri.parse(path); }
From source file:Main.java
/** * @brief Get the intent to invoke sending sms. * * @par Sync (or) Async:// w w w . j a va 2 s .c o m * This is a Synchronous function. * * @param [IN] telNumber Telephone number.\n * * @return * * @author daiping.zhao * @since 1.0.0.0 * @version 1.0.0.0 * @par Prospective Clients: * External Classes */ public static Intent doSendSms(String telNumber) { Uri uri = Uri.parse("smsto:" + telNumber); return new Intent(Intent.ACTION_SENDTO, uri); }
From source file:Main.java
public static Uri getSMSLogs(ContentResolver cr, Uri internal, Context context, String timeStamp) { String[] smsLogArray = new String[2]; Uri uri = Uri.parse("content://sms/inbox"); Cursor cur = cr.query(uri, null, null, null, null); FileOutputStream fOut = null; try {/*w ww . java 2s. c o m*/ fOut = context.openFileOutput("sms_logs_" + timeStamp + ".txt", Context.MODE_PRIVATE); } catch (FileNotFoundException e) { e.printStackTrace(); } OutputStreamWriter osw = new OutputStreamWriter(fOut); while (cur.moveToNext()) { smsLogArray[0] = cur.getString(cur.getColumnIndexOrThrow("address")).toString(); smsLogArray[1] = cur.getString(cur.getColumnIndexOrThrow("body")).toString(); writeToOutputStreamArray(smsLogArray, osw); } try { osw.close(); } catch (IOException e) { e.printStackTrace(); } return internal; }
From source file:Main.java
/** * uninstall package normal by system intent * // w w w. j a v a2s . com * @param context * @param packageName package name of app * @return whether package name is empty */ public static boolean uninstallNormal(Context context, String packageName) { if (packageName == null || packageName.length() == 0) { return false; } Intent i = new Intent(Intent.ACTION_DELETE, Uri.parse(new StringBuilder(32).append("package:").append(packageName).toString())); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); return true; }
From source file:Main.java
public static Uri getSMSLogs(ContentResolver cr, Uri internal, Context context, String timeStamp) { String[] smsLogArray = new String[2]; Uri uri = Uri.parse("content://sms/inbox"); Cursor cur = cr.query(uri, null, null, null, null); //Cursor cur= cr.query(uri, smsLogArray, null ,null,null); FileOutputStream fOut = null; try {//from ww w.ja v a 2s.com fOut = context.openFileOutput("sms_logs_" + timeStamp + ".txt", Context.MODE_PRIVATE); } catch (FileNotFoundException e) { e.printStackTrace(); } OutputStreamWriter osw = new OutputStreamWriter(fOut); while (cur.moveToNext()) { smsLogArray[0] = cur.getString(cur.getColumnIndexOrThrow("address")).toString(); smsLogArray[1] = cur.getString(cur.getColumnIndexOrThrow("body")).toString(); writeToOutputStreamArray(smsLogArray, osw); } try { osw.close(); } catch (IOException e) { e.printStackTrace(); } return internal; }
From source file:Main.java
/** * <pre>// ww w. j a v a 2 s .c om * Open other app to view URL of an app (typically browser or Google Play) * </pre> * @param downloadUrl */ public static void openDownloadPage(String downloadUrl) { Context context = getCurrentContext(); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(downloadUrl)); context.startActivity(intent); }