Example usage for android.content Intent setDataAndType

List of usage examples for android.content Intent setDataAndType

Introduction

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

Prototype

public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) 

Source Link

Document

(Usually optional) Set the data for the intent along with an explicit MIME data type.

Usage

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static void installAPK(Context context, File file) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
    context.startActivity(intent);//from w  w  w.j av a2s. c om
}

From source file:Main.java

public static void install(Context context, String mUrl) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(new File(mUrl)), "application/vnd.android.package-archive");
    context.startActivity(intent);//from w  w  w  . j  a v a2  s.  co  m
}

From source file:Main.java

public static void startInstall(Context context, Uri uri) {
    Intent install = new Intent(Intent.ACTION_VIEW);
    install.setDataAndType(uri, "application/vnd.android.package-archive");
    install.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(install);//from w  w  w.  j  a  v a 2s.  c  o m
}

From source file:Main.java

public static void installApk(Activity activity, String path) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(new File(path)), "application/vnd.android.package-archive");
    activity.startActivity(intent);//from ww  w. java  2s.co  m
}

From source file:Main.java

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

From source file:Main.java

public static void installApk(Context context, File apkFile) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);//from w  w  w.  j a v a2s  . c o m
}

From source file:Main.java

public static void installApk(Context context, String apkPath) {

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.parse("file://" + apkPath), "application/vnd.android.package-archive");

    context.startActivity(intent);/* w ww.  ja v a 2s.co  m*/
}

From source file:Main.java

public static void install(Context context, File file) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);/*from   w  w  w. jav a 2 s  .  co m*/
}