Example usage for android.content Intent setClassName

List of usage examples for android.content Intent setClassName

Introduction

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

Prototype

public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) 

Source Link

Document

Convenience for calling #setComponent with an explicit application package name and class name.

Usage

From source file:Main.java

public static boolean isActivityexist(Context context, String pkg, String cls) {
    Intent intent = new Intent();
    intent.setClassName(pkg, cls);
    return context.getPackageManager().resolveActivity(intent, 0) != null;
}

From source file:Main.java

public static void goMainActivity(Context context) {
    Intent intent = new Intent();
    intent.setClassName("com.nearucenterplaza.redenvelopeassistant",
            "com.nearucenterplaza.redenvelopeassistant.ui.activity.HomeActivity");
    context.startActivity(intent);//w w  w .j a v  a  2  s .  c  om
}

From source file:Main.java

public static boolean isActivityExists(Context context, String packageName, String className) {
    Intent intent = new Intent();
    intent.setClassName(packageName, className);
    return !(context.getPackageManager().resolveActivity(intent, 0) == null
            || intent.resolveActivity(context.getPackageManager()) == null
            || context.getPackageManager().queryIntentActivities(intent, 0).size() == 0);
}

From source file:Main.java

public static void showOperaBrowser(Context context, String visitUrl) {
    Intent intent = new Intent();
    intent.setClassName("com.opera.mini.android", "com.opera.mini.android.Browser");
    intent.setAction(Intent.ACTION_VIEW);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setData(Uri.parse(visitUrl));
    context.startActivity(intent);/*  w w w .j  a  va  2s. c o m*/
}

From source file:Main.java

public static void showUCBrowser(Context context, String visitUrl) {
    Intent intent = new Intent();
    intent.setClassName("com.uc.browser", "com.uc.browser.ActivityUpdate");
    intent.setAction(Intent.ACTION_VIEW);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setData(Uri.parse(visitUrl));
    context.startActivity(intent);//from  www. j a v  a 2 s . c  o m
}

From source file:Main.java

public static void showQQBrowser(Context context, String visitUrl) {
    Intent intent = new Intent();
    intent.setClassName("com.tencent.mtt", "com.tencent.mtt.MainActivity");
    intent.setAction(Intent.ACTION_VIEW);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setData(Uri.parse(visitUrl));
    context.startActivity(intent);/*from   ww  w . j  av a  2 s. c o  m*/
}

From source file:Main.java

private static void startActivityByResolve(Context context, ResolveInfo r, Intent intent) {
    Intent intent2 = new Intent(intent);
    intent2.setClassName(r.activityInfo.packageName, r.activityInfo.name);
    intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.getApplicationContext().startActivity(intent2);
}

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 final void openGPS(Context context) {
    Intent GPSIntent = new Intent();
    GPSIntent.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider");
    GPSIntent.addCategory("android.intent.category.ALTERNATIVE");
    GPSIntent.setData(Uri.parse("custom:3"));
    try {/*from w  ww.  java 2  s .  co m*/
        PendingIntent.getBroadcast(context, 0, GPSIntent, 0).send();
    } catch (PendingIntent.CanceledException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static Intent getPermissionmanagerIntent() {
    Intent intent = new Intent();
    intent.setClassName("com.huawei.systemmanager", "com.huawei.permissionmanager.ui.MainActivity");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    return intent;
}