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 openDownloadWeb(Context context, String url) {
    Uri uri = Uri.parse(url);
    Intent it = new Intent(Intent.ACTION_VIEW, uri);
    context.startActivity(it);//from  w ww.  j ava2  s .co m
}

From source file:Main.java

public static void openUrlInBrowser(Context context, String url) {
    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    context.startActivity(browserIntent);
}

From source file:Main.java

public static void openKindleApp(Context context) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("kindle:"));
    context.startActivity(intent);//from  w  w w . j  a va  2 s  . c om
}

From source file:Main.java

/** launch market to certain app */
public static void launchMarket(Context context, String packageName) {
    Uri uri = Uri.parse("market://details?id=" + packageName);
    Intent iDown = new Intent(Intent.ACTION_VIEW, uri);
    context.startActivity(iDown);//from ww  w. j a v a 2s . c  o  m
}

From source file:Main.java

public static void rateApplication(Context context) {
    Uri uri = Uri.parse("market://details?id=" + context.getPackageName());
    Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
    try {//from   w  w  w.  j  a v a2  s . co  m
        context.startActivity(goToMarket);
    } catch (ActivityNotFoundException e) {
        //            UtilityClass.showAlertDialog(context, ERROR, "Couldn't launch the market", null, 0);
    }
}

From source file:Main.java

public static void tell(String s, Activity activity) {
    if (!"".equals(getEmply(s))) {
        Uri uri = Uri.parse("tel:" + s);
        Intent it = new Intent(Intent.ACTION_DIAL, uri);
        activity.startActivity(it);//from  www.j  a va2  s .  co  m
    }
}

From source file:Main.java

public static boolean urlsMatchOnPath(String url1, String url2) {
    try {/*w w  w.j ava  2  s  .c  o  m*/
        Uri uri1 = Uri.parse(url1);
        Uri uri2 = Uri.parse(url2);
        String path1 = uri1.getPath();
        String path2 = uri2.getPath();

        if (path1.length() >= 2 && path1.substring(0, 2).equals("//"))
            path1 = path1.substring(1, path1.length());
        if (path2.length() >= 2 && path2.substring(0, 2).equals("//"))
            path2 = path2.substring(1, path2.length());

        if (path1.isEmpty())
            path1 = "/";
        if (path2.isEmpty())
            path2 = "/";

        String host1 = uri1.getHost();
        String host2 = uri2.getHost();
        if (host1.startsWith("www."))
            host1 = host1.substring(4);
        if (host2.startsWith("www."))
            host2 = host2.substring(4);

        return host1.equals(host2) && path1.equals(path2);
    } catch (Exception e) {
        return false;
    }
}

From source file:Main.java

public static void jump2Browser(Context context, String url) {
    Intent viewIntent = new Intent("android.intent.action.VIEW", Uri.parse(url));
    context.startActivity(viewIntent);/*from w  w  w . ja va2s  . c o m*/
}

From source file:Main.java

private static void openUrlInBrowser(Context context, String url) {
    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    context.startActivity(browserIntent);
}

From source file:Main.java

public static void call(Context context, String phoneNumber) {
    context.startActivity(new Intent("android.intent.action.CALL", Uri.parse("tel:" + phoneNumber)));
}