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

/**
 * Launches to the specific app in the Android Marketplace.
 *
 * @param context Application or Activity context
 * @param action Desired action/*from   ww  w  . j av  a  2  s . c  o m*/
 */
public static void launchToMarketplace(final Context context, final String action) {
    final Uri intentUri = Uri.parse("market://search?q=pname:" + action);

    final Intent intent = new Intent(Intent.ACTION_VIEW, intentUri);

    context.startActivity(intent);
}

From source file:Main.java

/**
 * Open a webpage with indicated http url
 * //from w ww  . j  a v a  2 s  .  c  o m
 * @param context   the application context
 * @param httpUrl   the http url to open
 */
public static void openWebPage(Context context, String httpUrl) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(httpUrl));
    context.startActivity(intent);
}

From source file:Main.java

public static void uninstallApk(Context context, String packageName) {
    if (context == null)
        return;/*  w  w w  . ja va 2  s  . co m*/
    if (TextUtils.isEmpty(packageName))
        return;
    Intent intent = new Intent(Intent.ACTION_DELETE);
    Uri packageURI = Uri.parse("package:" + packageName);
    intent.setData(packageURI);
    context.startActivity(intent);
}

From source file:Main.java

public static void openLink(Context context, String url) {
    if (url.equals("")) {
        return;// w ww  .  j  av a  2s  .  c  o  m
    }
    ;

    if (!url.startsWith("http://") && !url.startsWith("https://"))
        url = "http://" + url;

    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    browserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(browserIntent);
}

From source file:Main.java

public static void showUCBrowser(Context context, String visitUrl) {
    Intent intent = new Intent();
    intent.setClassName("com.uc.browser", "com.uc.browser.ActivityUpdate");
    intent.setAction(Intent.ACTION_VIEW);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setData(Uri.parse(visitUrl));
    context.startActivity(intent);/*from   w  w  w.j  a  v a 2 s .  c om*/
}

From source file:Main.java

public static void showQQBrowser(Context context, String visitUrl) {
    Intent intent = new Intent();
    intent.setClassName("com.tencent.mtt", "com.tencent.mtt.MainActivity");
    intent.setAction(Intent.ACTION_VIEW);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setData(Uri.parse(visitUrl));
    context.startActivity(intent);/*ww  w . j  a va2s  .c  o m*/
}

From source file:Main.java

public static void startDialer(Context context, String phoneNumber) {
    try {//w ww  .j  a  v  a2  s  .  c  o m
        Intent dial = new Intent();
        dial.setAction(Intent.ACTION_DIAL);
        dial.setData(Uri.parse("tel:" + phoneNumber));
        context.startActivity(dial);
    } catch (Exception ex) {
        Log.e(TAG, "Error starting phone dialer intent.", ex);
        Toast.makeText(context, "Sorry, we couldn't find any app to place a phone call!", Toast.LENGTH_SHORT)
                .show();
    }
}

From source file:Main.java

protected static boolean InstallServiceQuiet(Context context) {
    boolean result = true;
    try {/*from  w  ww.j  a  va2s . co m*/
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(OPEN_CV_SERVICE_URL));
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    } catch (Exception e) {
        result = false;
    }

    return result;
}

From source file:Main.java

public static boolean isPlayStoreInstalled(Context context) {
    if (null == context)
        return false;

    try {/*from   w  w w .j a v a2s  . c o m*/

        Intent market = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=dummy"));
        PackageManager manager = context.getPackageManager();
        List<ResolveInfo> list = manager.queryIntentActivities(market, 0);

        return list.size() > 0;
    } catch (Exception e) {
        return false;
    }
}

From source file:Main.java

public static ArrayList<String> getColumns(ContentResolver resolver, String uri, String[] projectionArray) {
    //String returnValue = "";
    ArrayList<String> columns = new ArrayList<String>();

    try {//from  w  w  w  .  j  a va2s. c  om
        //Issue query
        Cursor c = resolver.query(Uri.parse(uri), projectionArray, null, null, null);

        //Get all column names and display
        if (c != null) {
            String[] colNames = c.getColumnNames();

            //Close the cursor
            c.close();

            //String columnNamesOutput = "";
            for (int k = 0; k < colNames.length; k++)
                columns.add(colNames[k]);
        }
    } catch (Throwable t) {
    }

    return columns;

}