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 showDownloadSetting(Context context) {
    String packageName = "com.android.providers.downloads";
    Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    intent.setData(Uri.parse("package:" + packageName));
    if (intentAvailable(context, intent)) {
        context.startActivity(intent);//from  ww  w  .j av  a 2s. com
    }
}

From source file:Main.java

/**
 * Open the google play store market with this app
 * /*from   w w w .  j  a v a  2  s . c o  m*/
 * @param context the application context
 */
public static void openMarket(Context context) {
    Uri uri = Uri.parse("market://details?id=" + context.getPackageName());
    Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);

    try {
        context.startActivity(goToMarket);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(context, "Couldn't launch the market", Toast.LENGTH_SHORT).show();
    }
}

From source file:Main.java

/**
 * Creates an intent to open a link./*w  w  w .j  av a  2  s. c  o m*/
 *
 * @param url     The url to be opened.
 * @param context The context needed to start the intent.
 */
public static void openLink(String url, Context context) {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    context.startActivity(intent);
}

From source file:Main.java

public static boolean installApk(Context context, String filePath) {
    File file = new File(filePath);
    if (!file.exists() || !file.isFile() || file.length() <= 0) {
        return false;
    }/*from   w  ww. j a  v a 2s  .c o  m*/
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.android.package-archive");
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(i);
    return true;
}

From source file:Main.java

private static Uri uriFromString(StringBuilder s) {
    String str = toString(extract(s));
    Uri uri = str == null ? null : Uri.parse(str);
    return uri;
}

From source file:Main.java

public static boolean settings(Context context, PackageInfo packageInfo) {
    Intent intent = new Intent();
    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    intent.setData(Uri.parse("package:" + packageInfo.packageName));
    context.startActivity(intent);/* ww  w .  ja  v  a2 s  .  c  o  m*/
    return true;
}

From source file:Main.java

private static Intent getUninstallAppIntent(final String packageName, final boolean isNewTask) {
    Intent intent = new Intent(Intent.ACTION_DELETE);
    intent.setData(Uri.parse("package:" + packageName));
    return isNewTask ? intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) : intent;
}

From source file:Main.java

public static Cursor getAllCallLogs(ContentResolver cr) {
    // reading all data in descending order according to DATE
    String strOrder = android.provider.CallLog.Calls.DATE + " DESC";
    Uri callUri = Uri.parse("content://call_log/calls");
    Cursor curCallLogs = cr.query(callUri, null, null, null, strOrder);

    return curCallLogs;
}

From source file:Main.java

public static void shareFile(Context context, String title, String subject, String text, String mime,
        String path) {/*from   w  w w .j  a va2 s.  c om*/
    Intent sendIntent = new Intent(Intent.ACTION_SEND);
    sendIntent.setType(mime);
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + path));
    sendIntent.putExtra(Intent.EXTRA_TEXT, text);
    context.startActivity(Intent.createChooser(sendIntent, title));
}

From source file:Main.java

protected static void launchFallbackSupportUri(Context context) {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(FALLBACK_SUPPORT_URL));
    // Let Chrome know that this intent is from Chrome, so that it does not close the app when
    // the user presses 'back' button.
    intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
    intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
    intent.setPackage(context.getPackageName());
    context.startActivity(intent);//from   ww w.j  av  a 2 s . c o  m
}