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 goToWebPage(Context context, String url) {
    Uri uriUrl = Uri.parse(url);/*from w ww  . ja  va  2s . c om*/
    Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl);
    context.startActivity(launchBrowser);
}

From source file:Main.java

public static void link(Context context, Uri link) {
    context.startActivity(new Intent(Intent.ACTION_VIEW, link));
}

From source file:Main.java

public static void openBrowser(Activity activity, String url) {
    final Uri uri = Uri.parse(url);
    final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    activity.startActivityIfNeeded(intent, 0);
}

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 openWithBrowser(Activity activity, String url) {
    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    activity.startActivity(i);//from ww  w  . ja v  a2  s .c  o m
}

From source file:Main.java

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

From source file:Main.java

public static boolean playAudio(Context context, String mrl, String name) {
    try {//from w  ww.  j  av  a2s.c om
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.parse(mrl), "audio/*");
        context.startActivity(intent);
        return true;
    } catch (android.content.ActivityNotFoundException ex) {
    }
    return false;
}

From source file:Main.java

public static void startBrowser(Context context, String url) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(url));//from w  w w .j  a  va 2s .c o m
    context.startActivity(intent);
}

From source file:Main.java

public static void openDeveloperPageOnGooglePlay(Context context, String pubName) {
    try {//from w  w  w . java2  s.co m
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("market://search?q=pub:" + pubName));
        context.startActivity(intent);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:Main.java

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