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

From source file:Main.java

public static Intent getPlayServicesIntent() {
    return new Intent(Intent.ACTION_VIEW).setData(Uri.parse("market://details?id=com.google.android.gms"));
}

From source file:Main.java

public static void installApk(Context context, String path) {
    File file = new File(path);
    if (file.exists()) {
        Intent installIntent = new Intent(Intent.ACTION_VIEW);
        installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        installIntent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
        context.startActivity(installIntent);
    }/*from   w w  w  .  jav  a2s.  c  om*/
}

From source file:Main.java

public static void installBySys(Context context, File f) {
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(android.content.Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(f), "application/vnd.android.package-archive");
    context.startActivity(intent);/*from   w  w  w . j  ava  2s. c om*/
}

From source file:Main.java

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

From source file:Main.java

public static void install(Context context, String path) {
    if (TextUtils.isEmpty(path)) {
        return;/*from w ww .  j av  a2 s.c o m*/
    }
    Intent installIntent = new Intent(Intent.ACTION_VIEW);
    installIntent.setDataAndType(Uri.parse(path), "application/vnd.android.package-archive");
    context.startActivity(installIntent);
}

From source file:Main.java

public static void InstallApk(Context context, String path) {
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(android.content.Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(new File(path)), "application/vnd.android.package-archive");
    context.startActivity(intent);//from ww  w . j  a  v a 2s.c  o  m
}

From source file:Main.java

/** launch market to certain app */
public static void launchMarket(Context context, String packageName) {
    Uri uri = Uri.parse("market://details?id=" + packageName);
    Intent iDown = new Intent(Intent.ACTION_VIEW, uri);
    context.startActivity(iDown);//from   w  ww  . jav  a2  s .c  om
}

From source file:Main.java

public static Intent showOpenTypeDialog(String param) {
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(android.content.Intent.ACTION_VIEW);
    Uri uri = Uri.fromFile(new File(param));
    intent.setDataAndType(uri, "*/*");
    return intent;
}

From source file:Main.java

public static void intallApk(Context context, String filePath) {
    File apkfile = new File(filePath);
    if (!apkfile.exists())
        return;/*from   w  w  w .j  a  v  a  2  s  . com*/
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setDataAndType(Uri.parse("file://" + apkfile.toString()), "application/vnd.android.package-archive");
    context.startActivity(i);
}