Example usage for android.content ComponentName ComponentName

List of usage examples for android.content ComponentName ComponentName

Introduction

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

Prototype

private ComponentName(String pkg, Parcel in) 

Source Link

Usage

From source file:Main.java

public static ComponentName getComponentName(Context context) {
    return new ComponentName(context, context.getClass());
}

From source file:Main.java

public static boolean isEnabled(Context context, Class<?> clazz) {
    ComponentName componentName = new ComponentName(context, clazz);
    PackageManager pm = context.getPackageManager();
    return pm.getComponentEnabledSetting(componentName) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
}

From source file:Main.java

public static void openNet(Activity activity) {
    Intent intent = new Intent("/");
    ComponentName cm = new ComponentName("com.android.settings", "com.android.settings.WirelessSettings");
    intent.setComponent(cm);//from w  w  w .  jav a 2 s  .  c  o m
    intent.setAction("android.intent.action.VIEW");
    activity.startActivityForResult(intent, 0);
}

From source file:Main.java

public static void openSetting(Activity activity) {
    Intent intent = new Intent("/");
    ComponentName cm = new ComponentName("com.android.settings", "com.android.settings.WirelessSettings");
    intent.setComponent(cm);/* ww w.  j  a  v a 2 s  .c o  m*/
    intent.setAction("android.intent.action.VIEW");
    activity.startActivityForResult(intent, 0);
}

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 ww .j av  a2  s  .  c  om

}

From source file:Main.java

public static void openNetworkSetting(Activity activity) {
    Intent intent = new Intent("/");
    ComponentName cm = new ComponentName("com.android.settings", "com.android.settings.WirelessSettings");
    intent.setComponent(cm);/*from w w  w.  ja va  2 s. c om*/
    intent.setAction("android.intent.action.VIEW");
    activity.startActivityForResult(intent, 0);
}

From source file:Main.java

public static void openSetting(Activity activity, int requestCode) {
    Intent intent = new Intent("/");
    ComponentName cm = new ComponentName("com.android.settings", "com.android.settings.WirelessSettings");
    intent.setComponent(cm);/*from   w w w  . j  av a 2s  .c om*/
    intent.setAction(Intent.ACTION_VIEW);
    activity.startActivityForResult(intent, requestCode);
}

From source file:Main.java

public static void startMobileDataSettingActivity(Context context) {
    Intent mIntent = new Intent("/");
    ComponentName comp = new ComponentName("com.android.phone", "com.android.phone.Settings");
    mIntent.setComponent(comp);//from   w w w  . j  a  v  a 2  s  . co m
    mIntent.setAction("android.intent.action.VIEW");
    context.startActivity(mIntent);
}

From source file:Main.java

public static void setComponentEnabled(Class<?> componentClass, boolean enabled, Context context) {
    ComponentName componentName = new ComponentName(context, componentClass);
    PackageManager packageManager = context.getPackageManager();
    int state = enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
            : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
    packageManager.setComponentEnabledSetting(componentName, state, PackageManager.DONT_KILL_APP);
}

From source file:Main.java

public static final boolean checkServiceRunning(Context c, Class<? extends Service> cls) {
    ComponentName service = new ComponentName(c, cls);
    ActivityManager am = (ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE);
    if (am == null)
        throw new RuntimeException("Cannot check running services: ActivityManager is not available");
    for (ActivityManager.RunningServiceInfo runningService : am.getRunningServices(Integer.MAX_VALUE)) {
        if (runningService.service.equals(service))
            return true;
    }//from www .  j  a  v a 2  s  .  c o m
    return false;
}