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

private static Intent getImageFileIntent(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, "image/*");
    return intent;
}

From source file:Main.java

public static void jumpToHomeActivity(Context context) {
    Intent mHomeIntent = new Intent("android.intent.action.MAIN");
    mHomeIntent.addCategory("android.intent.category.HOME");
    mHomeIntent.addFlags(270532608);
    context.startActivity(mHomeIntent);/*from  w  w w .j ava2  s .c  o m*/
}

From source file:Main.java

public static void ShareApplication(Context mContext) {
    Intent intent = new Intent(android.content.Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    intent.putExtra(Intent.EXTRA_SUBJECT, "Search Sri Lanka Railway Time Table");
    intent.putExtra(Intent.EXTRA_TITLE, "Search Sri Lanka Railway Time Table");
    intent.putExtra(Intent.EXTRA_TEXT,//from  w w  w. j  a  va 2s . co m
            "Search \"Sri Lanka Railway Time Table\" on your Android. http://market.android.com/details?id=com.aselalee.trainschedule");
    mContext.startActivity(Intent.createChooser(intent, "Spread the word"));
    return;
}

From source file:Main.java

public static Intent getPptFileIntent(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, "application/vnd.ms-powerpoint");
    return intent;
}

From source file:Main.java

public static Intent getChmFileIntent(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, "application/x-chm");
    return intent;
}

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  ww .j  a  v  a  2  s . co  m
}

From source file:Main.java

private static Intent getIntentByType(String param, String type) {
    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, type);//  w w  w  .j  a va2s. c  o  m
    return intent;
}

From source file:Main.java

@SuppressLint("InlinedApi")
public static void launchPlainText(Context context, String text, CharSequence chooserTitle) {
    // See http://android-developers.blogspot.com/2012/02/share-with-intents.html
    Intent intent = new Intent(android.content.Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
    intent.putExtra(Intent.EXTRA_TEXT, text);
    // intent.putExtra( Intent.EXTRA_SUBJECT, subject );
    // intent.putExtra( Intent.EXTRA_EMAIL, new String[] { emailTo } );
    context.startActivity(Intent.createChooser(intent, chooserTitle));
}

From source file:Main.java

private static Intent getUninstallAppIntent(final String packageName, final boolean isNewTask) {
    Intent intent = new Intent(Intent.ACTION_DELETE);
    intent.setData(Uri.parse("package:" + packageName));
    return isNewTask ? intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) : intent;
}

From source file:Main.java

public static void openPDF(Context context, String path) {
    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(path));
    intent.setDataAndType(uri, "application/pdf");
    try {//from   w w w. j a v a  2s .  c o  m
        context.startActivity(intent);
    } catch (Exception e) {
        e.printStackTrace();
    }
}