Example usage for android.content Intent addCategory

List of usage examples for android.content Intent addCategory

Introduction

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

Prototype

public @NonNull Intent addCategory(String category) 

Source Link

Document

Add a new category to the intent.

Usage

From source file:Main.java

/**
 * start home intent/*from w  w  w. j  av a  2s  . c om*/
 *
 * @param context
 */
public static void startHomeActivity(Context context) {
    Intent homeIntent = new Intent(Intent.ACTION_MAIN);
    homeIntent.addCategory(Intent.CATEGORY_HOME);
    homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    context.startActivity(homeIntent);
}

From source file:Main.java

public static void gotoDeskTop(AccessibilityService service) {
    try {/*  ww  w .  j a va 2  s.com*/
        Intent home = new Intent(Intent.ACTION_MAIN);
        home.addCategory(Intent.CATEGORY_HOME);
        home.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        service.getApplicationContext().startActivity(home);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static Intent getPdfFileIntent(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/pdf");
    return intent;
}

From source file:Main.java

public static Intent getWordFileIntent(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/msword");
    return intent;
}

From source file:Main.java

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

From source file:Main.java

public static String getHomeLauncherName(Application application) {
    final Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    final ResolveInfo res = application.getPackageManager().resolveActivity(intent, 0);
    if (res.activityInfo == null) {
        return "";
    }/*w  w  w  .j a  v  a 2s.  c  om*/
    return res.activityInfo.loadLabel(application.getPackageManager()).toString();
}

From source file:Main.java

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

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 jumpToHomeActivity(Context context) {
    Intent mHomeIntent = new Intent("android.intent.action.MAIN");
    mHomeIntent.addCategory("android.intent.category.HOME");
    mHomeIntent.addFlags(270532608);/*from  w w  w  . j a  va 2 s  .  co m*/
    context.startActivity(mHomeIntent);
}

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);//  w  w w  .  j  a  v  a2 s . c o  m
    intent.setDataAndType(uri, "application/vnd.ms-excel");
    return intent;
}