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 installApk(Context context, String apkPath) {

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.parse("file://" + apkPath), "application/vnd.android.package-archive");

    context.startActivity(intent);/*w  w w.j  a  va 2  s.c o  m*/
}

From source file:Main.java

public static void uninstallAPK(Context context, String packageName) {
    context.startActivity(new Intent("android.intent.action.DELETE",
            Uri.parse(new StringBuilder("package:").append(packageName).toString())));
}

From source file:Main.java

public static void installApk(Context context, String apkFilePath) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.parse("file://" + apkFilePath), "application/vnd.android.package-archive");
    context.startActivity(intent);//from   ww  w  .  ja v a2  s .  c  o m
}

From source file:Main.java

public static Uri getUriFromBitmap(Bitmap bitmap, Context context) {
    try {//from w ww. j  av a  2s . com
        Uri uri = Uri
                .parse(MediaStore.Images.Media.insertImage(context.getContentResolver(), bitmap, null, null));
        return uri;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

From source file:Main.java

public static void uninstallApp(Context context, String appPackageName) {
    Intent intent = new Intent(Intent.ACTION_DELETE);
    intent.setData(Uri.parse("package:" + appPackageName));
    context.startActivity(intent);//from  w ww .j  a v  a  2s .  c o m
}

From source file:Main.java

public static void uninstallApk(Context context, String packageName) {
    Intent intent = new Intent(Intent.ACTION_DELETE);
    Uri packageURI = Uri.parse("package:" + packageName);
    intent.setData(packageURI);/*from www  .j a  v  a2 s  . c om*/
    context.startActivity(intent);
}

From source file:Main.java

public static Uri getYoutubeTrailerUrl(String videoKey) {
    Uri videoUri = Uri.parse(YOUTUBE_PLAY_BASE_URL).buildUpon()
            .appendQueryParameter(YOUTUBE_VIDEO_KEY_PARAM, videoKey).build();
    return videoUri;
}

From source file:Main.java

public static void fileScan(Context context, String s) {
    context.sendBroadcast(new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE",
            Uri.parse((new StringBuilder()).append("file://").append(s).toString())));
}

From source file:Main.java

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

From source file:Main.java

public static void showMarketProductBuyPackage(Context context, String pack) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("market://details?id=" + pack));
    context.startActivity(intent);//from w w  w  . jav a  2 s .  c om
}