Example usage for android.content Intent addFlags

List of usage examples for android.content Intent addFlags

Introduction

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

Prototype

public @NonNull Intent addFlags(@Flags int flags) 

Source Link

Document

Add additional flags to the intent (or with existing flags value).

Usage

From source file:Main.java

public static Intent getImageFileIntent(String param) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(new File(param));
    intent.setDataAndType(uri, "image/*");
    return intent;
}

From source file:Main.java

public static void jumpToSystemCallActivity(Context context, String number) {
    Intent i = new Intent();
    i.setAction("android.intent.action.CALL");
    i.setData(Uri.parse("tel:" + number));
    i.addFlags(268435456);
    context.startActivity(i);/*w w w.  j  av a2s  . c  o  m*/
}

From source file:Main.java

private static Intent getExcelFileIntent(File file) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(file);//from  w  w  w . ja  va 2s. c o  m
    intent.setDataAndType(uri, "application/vnd.ms-excel");
    return intent;
}

From source file:Main.java

private static Intent getPdfFileIntent(File file) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(file);//from   w  w w .j a  v a  2  s  . c o m
    intent.setDataAndType(uri, "application/pdf");
    return intent;
}

From source file:Main.java

private static Intent getChmFileIntent(String filePath) {

    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(new File(filePath));
    intent.setDataAndType(uri, "application/x-chm");
    return intent;
}

From source file:Main.java

private static Intent getPPTFileIntent(File file) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(file);// ww  w  .jav a  2 s  .co  m
    intent.setDataAndType(uri, "application/vnd.ms-powerpoint");
    return intent;
}

From source file:Main.java

private static Intent getWordFileIntent(String filePath) {

    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(new File(filePath));
    intent.setDataAndType(uri, "application/msword");
    return intent;
}

From source file:Main.java

private static Intent getWordFileIntent(File file) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(file);/*ww w . j  a v  a  2 s  .c  o m*/
    intent.setDataAndType(uri, "application/msword");
    return intent;
}

From source file:Main.java

private static Intent getTextFileIntent(File file) {
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(file);/*from   w  w w  .j a v a  2 s  . com*/
    intent.setDataAndType(uri, "text/plain");
    return intent;
}

From source file:Main.java

private static Intent getExcelFileIntent(String filePath) {

    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(new File(filePath));
    intent.setDataAndType(uri, "application/vnd.ms-excel");
    return intent;
}