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 install(Activity activity, File apkFile) {
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(android.content.Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
    activity.startActivity(intent);//from w ww  . ja  va2  s. c om
}

From source file:Main.java

public static void installApk(Context context, String filePath) {
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(new File(filePath)), "application/vnd.android.package-archive");
    context.startActivity(intent);//from   ww  w.  j a va 2  s.  com
}

From source file:Main.java

public static Intent openFile(Uri uri, String mimeType) {
    final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    intent.setType(mimeType);/*from   ww w .j  ava 2  s. c o  m*/
    return intent;
}

From source file:Main.java

public static boolean isGooglePlayInstalled(Context ctx) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("market://search?q=foo"));
    PackageManager pm = ctx.getPackageManager();
    List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);
    if (list.size() > 0) {
        return true;
    } else {/*from w  w w .j  av a  2 s.co m*/
        return false;
    }
}

From source file:Main.java

public static void goMarket(Context context, String pkgname) {
    // Intent marketIntent = new Intent(Intent.ACTION_VIEW,
    // Uri.parse("market://details?id=com.google.zxing.client.android"));
    Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + pkgname));
    context.startActivity(marketIntent);
}

From source file:Main.java

public static void searchMarket(Activity caller, String paramtype, String value) {
    Uri uri = Uri.parse("market://search?q=" + paramtype + ":" + value);
    Intent intent = new Intent();
    intent.setData(uri);//from www  .  ja  v  a2 s  . co  m
    intent.setAction(Intent.ACTION_VIEW);
    caller.startActivity(intent);
}

From source file:Main.java

public static boolean showMap(Context context, String address) {
    Uri addressUri = Uri.parse("geo:0,0?q=" + address);
    Intent searchAddress = new Intent(Intent.ACTION_VIEW, addressUri);

    boolean ret = true;
    try {/*from   w w  w .  java2  s .c o  m*/
        context.startActivity(searchAddress);
    } catch (Exception e) {
        ret = false;
    }
    return ret;
}

From source file:Main.java

public static void loadUrlInExternalBrowser(Context context, String url) {
    try {// w w  w .  j av  a 2 s.c o  m
        Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        context.startActivity(browserIntent);
    } catch (Exception ignored) {
    }
}

From source file:Main.java

public static Intent createViewIntent(@NonNull Uri uri) {
    return new Intent(Intent.ACTION_VIEW, uri);
}

From source file:Main.java

/**
 * Open Calendar app with specific time//  w w w  . j  a v  a  2s  .co m
 */
public static void openCalendar(Activity activity, long epochEventStartTime) {
    Uri uri = Uri.parse("content://com.android.calendar/time/" + epochEventStartTime);
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(uri);
    intent.putExtra("VIEW", "DAY");
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    activity.startActivity(intent);
}