Example usage for android.content Intent ACTION_VIEW

List of usage examples for android.content Intent ACTION_VIEW

Introduction

In this page you can find the example usage for android.content Intent ACTION_VIEW.

Prototype

String ACTION_VIEW

To view the source code for android.content Intent ACTION_VIEW.

Click Source Link

Document

Activity Action: Display the data to the user.

Usage

From source file:Main.java

public static void installApk(Context context, String apkPath) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(new File(apkPath)), "application/vnd.android.package-archive");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);// ww  w. j a v  a2 s .c  om
}

From source file:Main.java

public static void installApkWithPrompt(File apkFile, Context context) {
    Intent promptInstall = new Intent(Intent.ACTION_VIEW);
    promptInstall.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
    context.startActivity(promptInstall);
}

From source file:Main.java

public static Intent getSysAppDetailIntent(Context context) {
    return new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName()));
}

From source file:Main.java

public static void openURL(Context mContext, String url) {
    Uri uri = Uri.parse(url);// w  ww . j  a v a2s. co  m
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    mContext.startActivity(intent);
}

From source file:Main.java

/**
 * When doing a web search, there are two situations.
 *
 * If user type in a url or something similar to a url, we need to
 * open the url directly for user. Otherwise, we just search the
 * content user type in with default search engine.
 *
 * @param str content user want to search or url user want to visit
 * @return intent/* w  ww  .j a v  a  2 s.  com*/
 */
public static Intent getWebSearchIntent(String str) {
    Intent intent;
    // if search content contain ".", we think it's a url
    if (str.contains(".")) {
        if (!str.startsWith("http://") && !str.startsWith("https://"))
            str = "http://" + str;
        intent = new Intent(Intent.ACTION_VIEW, Uri.parse(str));
    } else {
        intent = new Intent(Intent.ACTION_WEB_SEARCH);
        intent.putExtra(SearchManager.QUERY, str);
    }
    return intent;
}

From source file:Main.java

public static void openURL(Context context, String url) {
    Intent i = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url));
    context.startActivity(i);//w ww.  j  av  a 2 s  .c o m
}

From source file:Main.java

public static void openSupportPage(Context context) {
    Uri supportUri = Uri.parse("https://notisync.uservoice.com");
    Intent intent = new Intent(Intent.ACTION_VIEW, supportUri);
    context.startActivity(intent);/* w w  w .  ja  va  2s . co m*/
}

From source file:Main.java

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

From source file:Main.java

public static void launchUrl(String url, Context context) {
    if (!url.isEmpty() && context != null) {
        context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
    }/*ww  w.  j  a  v a  2  s .  co  m*/
}

From source file:Main.java

public static void sedSMS(Context context, String phone) {
    Uri uri = Uri.parse("smsto:" + phone);
    Intent sendIntent = new Intent(Intent.ACTION_VIEW, uri);
    sendIntent.putExtra("sms_body", "");
    context.startActivity(sendIntent);/*from   w  ww  . ja  va  2  s .  co  m*/
}