Example usage for android.content Intent setComponent

List of usage examples for android.content Intent setComponent

Introduction

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

Prototype

public @NonNull Intent setComponent(@Nullable ComponentName component) 

Source Link

Document

(Usually optional) Explicitly set the component to handle the intent.

Usage

From source file:Main.java

public static void openYYB2(Context context) {

    Intent intent2 = new Intent();
    intent2.setComponent(new ComponentName("com.tencent.android.qqdownloader",
            "com.connector.tencent.connector.ConnectionActivity"));
    intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent2);//from   w  w w .  ja va2  s . co  m

}

From source file:Main.java

public static void intentSetting(Context context) {
    String pkg = "com.android.settings";
    String cls = "com.android.settings.Settings";

    ComponentName component = new ComponentName(pkg, cls);
    Intent intent = new Intent();
    intent.setComponent(component);

    context.startActivity(intent);/*from  ww  w .  j av  a2  s .  co m*/
}

From source file:Main.java

/**
 * @return an {@code Intent} to launch the given {@code packageName, name} with {@code replaceKey}.
 *//*  w  w  w .  j ava2 s  .  c  o m*/
public static Intent createMushroomLaunchingIntent(String packageName, String name, String replaceKey) {
    Intent intent = new Intent(ACTION);
    intent.setComponent(new ComponentName(packageName, name));
    intent.addCategory(CATEGORY);
    intent.putExtra(KEY, replaceKey);
    return intent;
}

From source file:Main.java

public static void startPackage(Activity activity, String s, String s1, Bundle bundle) {
    Intent intent = new Intent();
    intent.setComponent(new ComponentName(s, s1));
    intent.putExtras(bundle);/*ww w  .  jav a  2 s  .c om*/
    activity.startActivity(intent);
}

From source file:Main.java

/**
 * This method is used for opening any activity from another application. In this case we must ensure that
 * the desired activity is set to "exported". Such as in manifest file:
 *
 * <activity//from   ww  w.  j ava  2 s. c  om
 *     android:name=".activity.DesiredActivity"
 *     android:exported="true"
 *     android:screenOrientation="portrait">
 * </activity>
 *
 *
 *
 * @param context                                The context of the activity.
 * @param desiredPackageName                     The package name of the desired or another application.
 * @param desiredActivityNameWithFullPackageName The full path of the activity. Such as : com.example.activity.DesiredActivity
 */
public static void launchActivityFromAnotherApp(Context context, String desiredPackageName,
        String desiredActivityNameWithFullPackageName) {
    Intent intent = new Intent();
    intent.setComponent(new ComponentName(desiredPackageName, desiredActivityNameWithFullPackageName));
    context.startActivity(intent);
}

From source file:Main.java

public static Intent getSettingLSWallpaperIntent() {
    Intent intent = new Intent();
    intent.setComponent(new ComponentName("com.asus.launcher", "com.asus.themeapp.ThemeAppActivity"));
    intent.addFlags(//from w  w w  .j  a  va 2s. c  om
            Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    intent.putExtra("tabPosition", 1);
    return intent;
}

From source file:Main.java

public static Intent getSettingLSThemeIntent() {
    Intent intent = new Intent();
    intent.setComponent(new ComponentName("com.asus.themeapp", "com.asus.themeapp.ThemeAppActivity"));
    intent.addFlags(//  w w  w .j  a  v  a2s  .  c om
            Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    intent.putExtra("from", "com.android.systemui.lockscreen");
    return intent;
}

From source file:Main.java

public static Intent actionNewAccountIntent(final Context context) {
    final Intent i = new Intent();
    i.setComponent(new ComponentName(context, "com.android.email.activity.setup.AccountSetupFinal"));
    i.putExtra(EXTRA_FLOW_MODE, FLOW_MODE_NORMAL);
    return i;/*from  w  w  w.  ja  va2 s.  c o m*/
}

From source file:Main.java

public static Intent actionNewAccountWithResultIntent(final Context context) {
    final Intent i = new Intent();
    i.setComponent(new ComponentName(context, "com.android.email.activity.setup.AccountSetupFinal"));
    i.putExtra(EXTRA_FLOW_MODE, FLOW_MODE_NO_ACCOUNTS);
    return i;/*from  w ww  . j av a2  s. c  o m*/
}

From source file:Main.java

public static Intent actionGetCreateAccountIntent(final Context context, final String accountManagerType) {
    final Intent i = new Intent();
    i.setComponent(new ComponentName(context, "com.android.email.activity.setup.AccountSetupFinal"));
    i.putExtra(EXTRA_FLOW_MODE, FLOW_MODE_ACCOUNT_MANAGER);
    i.putExtra(EXTRA_FLOW_ACCOUNT_TYPE, accountManagerType);
    return i;//from  w  ww  .  j  a va 2 s  .  c  o  m
}