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

public static void callPhone(Context context, String number) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_DIAL);
    intent.setData(Uri.parse(String.format("tel:%s", number)));
    context.startActivity(intent);//from   ww  w. j a  va 2  s  .  c o m
}

From source file:Main.java

public static void call(Activity activity, String mobile) {
    try {/*from www .  j a  va  2 s. com*/
        Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:" + mobile));
        activity.startActivity(callIntent);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static boolean jump(Context context, String s) {
    Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(s));
    boolean flag;
    if (!isIntentAvailable(context, intent)) {
        Log.e("MicroMsg.Util", (new StringBuilder("jump to url failed, ")).append(s).toString());
        flag = false;/*  w  ww.  jav  a2 s .  c o  m*/
    } else {
        context.startActivity(intent);
        flag = true;
    }
    return flag;
}

From source file:Main.java

public static Intent newTelIntent(String telurl) {
    Intent intent = new Intent(Intent.ACTION_DIAL);
    // FIXME : need to check XXX is really a short number in tel:XXX 
    intent.setData(Uri.parse(telurl));
    return intent;
}

From source file:Main.java

public static void uninstall(Context context, String pkgname) {

    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_DELETE);
    intent.setData(Uri.parse("package:" + pkgname));
    context.startActivity(intent);/*from ww  w  .  j  a v  a2s  . com*/
}

From source file:Main.java

public static Uri resourceIdToUri(Context context, int resourceId) {
    return Uri.parse(ANDROID_RESOURCE + context.getPackageName() + FOREWARD_SLASH + resourceId);
}

From source file:Main.java

/**  -----------------------------------------------------------------------  Play Store -- */

public static Intent newOpenStoreIntent(String packageName) {
    return new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName));
}

From source file:Main.java

public static void gotoWeb(Context context, String url) {
    try {/*from  ww  w.j a v  a2s  .c o m*/
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(url));
        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY
                | Intent.FLAG_FROM_BACKGROUND);
        // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void showWebPage(Context context, String url) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");
    Uri uri = Uri.parse(url);
    intent.setData(uri);//from  w  w  w.  j  a v a 2s  . c  o m
    context.startActivity(intent);
}

From source file:Main.java

public static void intentDirection(Context context, double latitude, double longitude) {
    Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
            Uri.parse("http://maps.google.com/maps?daddr=" + latitude + "," + longitude));
    context.startActivity(intent);/*from   w  ww.  j  av a  2s  . c om*/
}