Example usage for android.net Uri parse

List of usage examples for android.net Uri parse

Introduction

In this page you can find the example usage for android.net Uri parse.

Prototype

public static Uri parse(String uriString) 

Source Link

Document

Creates a Uri which parses the given encoded URI string.

Usage

From source file:Main.java

@Deprecated
public static void uninstallApk2(Context context, String packageName) {
    Intent intent = new Intent(Intent.ACTION_DELETE);
    Uri packageURI = Uri.parse("package:" + packageName);
    intent.setData(packageURI);//from  ww w  .  ja  va2  s  .  co  m
    context.startActivity(intent);
}

From source file:Main.java

public static void directDial(String phoneNumber, Activity activity) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_CALL);
    intent.setData(Uri.parse("tel:" + phoneNumber));
    activity.startActivity(intent);// w  w w . ja v a 2s  .  c om
}

From source file:Main.java

public static Uri getDrawableUri(Context context, int resId) {
    Resources resources = context.getResources();
    return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + resources.getResourcePackageName(resId)
            + '/' + resources.getResourceTypeName(resId) + '/' + resources.getResourceEntryName(resId));
}

From source file:Main.java

public static void link(Context context, String url) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.addCategory(Intent.CATEGORY_BROWSABLE);
    intent.setData(Uri.parse(url));
    context.startActivity(intent);/*w w w  .  j  a v a  2s  .  c  o  m*/
}

From source file:Main.java

public static void showViewDial(String phoneNumber, Activity activity) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_DIAL);
    intent.setData(Uri.parse("tel:" + phoneNumber));
    activity.startActivity(intent);//from www  .  ja v  a  2  s .  c o m
}

From source file:Main.java

/**
 * Dial a ussd code//  ww  w. j  a v a2  s  .c o  m
 */
public static void dailNumber(Context context, String telNo) {
    String ussdCode = telNo + Uri.encode("#");
    context.startActivity(new Intent("android.intent.action.CALL", Uri.parse("tel:" + ussdCode)));
}

From source file:Main.java

public static String getNewThreadID(Context context) {
    int new_id = 0;
    final String[] projection = new String[] { "_id" };
    Uri uri = Uri.parse("content://mms-sms/conversations?simple=true");
    Cursor query = context.getContentResolver().query(uri, projection, null, null, "date DESC");
    if (query != null) {
        while (query.moveToNext()) {
            int tmp = query.getInt(query.getColumnIndexOrThrow("_id")) + 1;
            if (tmp > new_id) {
                new_id = tmp;
            }/*from   ww  w  .  jav  a2 s.c o m*/
        }
        query.close();
    }
    return "" + new_id;
}

From source file:Main.java

public static void callByPhone(Context context, String phone) {
    if (TextUtils.isEmpty(phone)) {
        return;// w ww  . j a  va 2s  .c  o  m
    }

    Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phone));
    context.startActivity(intent);
}

From source file:Main.java

/**
 * use for oepn any url in browser.// w  w w  .  j  a v  a2 s . c  om
 *
 * @param mContext
 * @param url      to open in your mobile browser
 */
public static void openURL(Context mContext, String url) {
    Uri uri = Uri.parse(url);
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    mContext.startActivity(intent);
}

From source file:Main.java

public static Uri getURIFromResrouceID(Context context, int resId) {
    Resources resources = context.getResources();
    Uri u = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + resources.getResourcePackageName(resId)
            + '/' + resources.getResourceTypeName(resId) + '/' + resources.getResourceEntryName(resId));
    return u;/*www.  j  a va 2  s.c  o m*/
}