Example usage for android.content Intent ACTION_MAIN

List of usage examples for android.content Intent ACTION_MAIN

Introduction

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

Prototype

String ACTION_MAIN

To view the source code for android.content Intent ACTION_MAIN.

Click Source Link

Document

Activity Action: Start as a main entry point, does not expect to receive data.

Usage

From source file:Main.java

public static Intent getNetworksOperatorsIntent() {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setClassName("com.android.phone", "com.android.phone.NetworkSetting");
    return intent;
}

From source file:Main.java

public static void showDesk(Context context) {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addCategory(Intent.CATEGORY_HOME);
    context.startActivity(intent);/*from   ww  w. j  a va 2s . c  om*/
}

From source file:Main.java

public static void jumpHome(Context context) {
    Intent startMain = new Intent(Intent.ACTION_MAIN);
    startMain.addCategory(Intent.CATEGORY_HOME);
    context.startActivity(startMain);/*w  ww. j  a  va 2 s.  c o  m*/
}

From source file:Main.java

public static final void gotoHome(Context context) {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addCategory(Intent.CATEGORY_HOME);
    context.startActivity(intent);// w  w w . j a  v a 2s  .  c o  m
}

From source file:Main.java

static void showDesktop(Context ctx) {
    Intent mHomeIntent;//w  ww .j a  v  a  2 s . co m
    mHomeIntent = new Intent(Intent.ACTION_MAIN, null);
    mHomeIntent.addCategory(Intent.CATEGORY_HOME);
    mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    ctx.startActivity(mHomeIntent);
}

From source file:Main.java

public static void imitateHome(Context context) {
    try {//from  www . j a  v  a2 s  . c  o m
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addCategory(Intent.CATEGORY_HOME);
        context.startActivity(intent);
    } catch (Exception e) {
        // TODO: handle exception
    }
}

From source file:Main.java

public static void takeMyselfToForeground(Context context, Class launcher) {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setClass(context, launcher);/*from   w  ww.j a  va 2  s  . com*/
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    context.startActivity(intent);
}

From source file:Main.java

public static Intent createLaunchIntent(ComponentName componentName) {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setComponent(componentName);// www. ja va 2  s. c om
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    return intent;
}

From source file:Main.java

public static void startLauncher(Context context) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    context.startActivity(intent);/*from  ww w  .  j  a v  a 2s .com*/
}

From source file:Main.java

public static void toHome(Context context) {
    Intent i = new Intent(Intent.ACTION_MAIN);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i.addCategory(Intent.CATEGORY_HOME);
    context.startActivity(i);//from  w w  w . j a v  a2 s  .  c  om
}