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 OpenURL(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 openUrl(Context context, String url) {
    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    context.startActivity(browserIntent);
}

From source file:Main.java

private static Intent getComponentIntent(String packageName, String className, Bundle bundle) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    if (bundle != null)
        intent.putExtras(bundle);//  ww  w. ja v  a  2  s  . c om
    ComponentName cn = new ComponentName(packageName, className);
    intent.setComponent(cn);
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}

From source file:Main.java

public static void openApplicationOnGooglePlay(Context context, String packageName) {
    try {/*from   w ww  . j a  va  2  s  .com*/
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("market://details?id=" + packageName));
        context.startActivity(intent);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:Main.java

public static boolean installApk(Context context, String archiveFilePath) {
    try {//from   w  ww .j  av a2s  .c o  m
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setDataAndType(Uri.parse("file:///" + archiveFilePath),
                "application/vnd.android.package-archive");
        context.startActivity(intent);
        return true;
    } catch (Exception e) {
        return false;
    }
}

From source file:Main.java

public static void intentPlaystore(Context context, String url) {
    Uri marketUri = Uri.parse(url);// www.ja  v  a  2 s .  co  m
    Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri);
    context.startActivity(marketIntent);
}

From source file:Main.java

public static void startSearchPlayApplication(Context mContext, String pkgName) {
    try {/*from  w  w w .j  a va  2 s  . c o  m*/
        Intent mIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + pkgName));
        mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mContext.startActivity(mIntent);
    } catch (android.content.ActivityNotFoundException anfe) {
        Intent mIntent1 = new Intent(Intent.ACTION_VIEW,
                Uri.parse("https://play.google.com/store/apps/details?id=" + pkgName));
        mIntent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mContext.startActivity(mIntent1);
    }
}

From source file:Main.java

public static void playVideo(String url, Activity activity) {
    if (url != null && url.length() > 0) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.parse(url), "video/*");
        activity.startActivity(intent);//from   w  w w.ja v  a2 s .c om
    }
}

From source file:Main.java

/**  -----------------------------------------------------------------------  External URL -- */

public static Intent newExternalUrlIntent(String url) {
    return new Intent(Intent.ACTION_VIEW, Uri.parse(url));
}

From source file:Main.java

public static void installAPK(Context context, String apkFile) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);

    intent.setDataAndType(Uri.fromFile(new File(apkFile)), "application/vnd.android.package-archive");
    context.startActivity(intent);//from  w  ww .ja v  a  2 s. com
}