List of usage examples for android.content.pm PackageManager DONT_KILL_APP
int DONT_KILL_APP
To view the source code for android.content.pm PackageManager DONT_KILL_APP.
Click Source Link
From source file:com.kaliturin.blacklist.utils.DefaultSMSAppHelper.java
public static void enableSMSReceiving(Context context, boolean enable) { int state = (enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED); PackageManager packageManager = context.getPackageManager(); ComponentName componentName = new ComponentName(context, SMSBroadcastReceiver.class); packageManager.setComponentEnabledSetting(componentName, state, PackageManager.DONT_KILL_APP); }
From source file:damo.three.ie.prepay.ConnectivityReceiver.java
/** * Enables ConnectivityReceiver/*from w ww .j av a 2 s .c om*/ */ public static void enableReceiver(Context context) { ComponentName component = new ComponentName(context, ConnectivityReceiver.class); context.getPackageManager().setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); }
From source file:org.proninyaroslav.libretorrent.settings.SettingsManager.java
public static void initPreferences(Context context) { SettingsManager pref = new SettingsManager(context); String keyAutostart = context.getString(R.string.pref_key_autostart); int flag = (pref.getBoolean(keyAutostart, false) ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED); ComponentName bootReceiver = new ComponentName(context, BootReceiver.class); context.getPackageManager().setComponentEnabledSetting(bootReceiver, flag, PackageManager.DONT_KILL_APP); String keySaveTorrentIn = context.getString(R.string.pref_key_save_torrents_in); if (pref.getString(keySaveTorrentIn, null) == null) { pref.put(keySaveTorrentIn, FileIOUtils.getDefaultDownloadPath()); }/*from w ww. ja va2 s .co m*/ String keyFileManagerLastDir = context.getString(R.string.pref_key_filemanager_last_dir); if (pref.getString(keyFileManagerLastDir, null) == null) { pref.put(keyFileManagerLastDir, FileIOUtils.getDefaultDownloadPath()); } String keyMoveAfterDownloadIn = context.getString(R.string.pref_key_move_after_download_in); if (pref.getString(keyMoveAfterDownloadIn, null) == null) { pref.put(keyMoveAfterDownloadIn, FileIOUtils.getDefaultDownloadPath()); } String keyMaxDownloadSpeedLimit = context.getString(R.string.pref_key_max_download_speed); if (pref.getInt(keyMaxDownloadSpeedLimit, -1) == -1) { pref.put(keyMaxDownloadSpeedLimit, 0); } String keyMaxUploadSpeedLimit = context.getString(R.string.pref_key_max_upload_speed); if (pref.getInt(keyMaxUploadSpeedLimit, -1) == -1) { pref.put(keyMaxUploadSpeedLimit, 0); } String keyMaxConnections = context.getString(R.string.pref_key_max_connections); if (pref.getInt(keyMaxConnections, -1) == -1) { pref.put(keyMaxConnections, TorrentEngine.DEFAULT_CONNECTIONS_LIMIT); } String keyMaxActiveUploads = context.getString(R.string.pref_key_max_active_uploads); if (pref.getInt(keyMaxActiveUploads, -1) == -1) { pref.put(keyMaxActiveUploads, TorrentEngine.DEFAULT_ACTIVE_SEEDS); } String keyMaxActiveDownloads = context.getString(R.string.pref_key_max_active_downloads); if (pref.getInt(keyMaxActiveDownloads, -1) == -1) { pref.put(keyMaxActiveDownloads, TorrentEngine.DEFAULT_ACTIVE_DOWNLOADS); } String keyMaxActiveTorrents = context.getString(R.string.pref_key_max_active_torrents); if (pref.getInt(keyMaxActiveTorrents, -1) == -1) { pref.put(keyMaxActiveTorrents, TorrentEngine.DEFAULT_ACTIVE_LIMIT); } String keyNotifySound = context.getString(R.string.pref_key_notify_sound); if (pref.getString(keyMaxActiveTorrents, null) == null) { pref.put(keyNotifySound, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION).toString()); } String keyLedIndicatorColor = context.getString(R.string.pref_key_led_indicator_color_notify); if (pref.getInt(keyLedIndicatorColor, -1) == -1) { pref.put(keyLedIndicatorColor, ContextCompat.getColor(context, R.color.primary)); } String keyProxyType = context.getString(R.string.pref_key_proxy_type); if (pref.getInt(keyProxyType, -1) == -1) { pref.put(keyProxyType, Integer.parseInt(context.getString(R.string.pref_proxy_type_none_value))); } String keyProxyPort = context.getString(R.string.pref_key_proxy_port); if (pref.getInt(keyProxyPort, -1) == -1) { pref.put(keyProxyPort, TorrentEngine.DEFAULT_PROXY_PORT); } String keyEncryptMode = context.getString(R.string.pref_key_enc_mode); if (pref.getInt(keyEncryptMode, -1) == -1) { pref.put(keyEncryptMode, Integer.parseInt(context.getString(R.string.pref_enc_mode_prefer_value))); } }
From source file:damo.three.ie.prepay.ConnectivityReceiver.java
/** * Disables ConnectivityReceiver//w w w . j a va 2 s.co m */ private static void disableReceiver(Context context) { ComponentName component = new ComponentName(context, ConnectivityReceiver.class); context.getPackageManager().setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); }
From source file:com.farmerbb.taskbar.receiver.DisableHomeReceiver.java
@Override public void onReceive(Context context, Intent intent) { SharedPreferences pref = U.getSharedPreferences(context); pref.edit().putBoolean("launcher", false).apply(); ComponentName component = new ComponentName(context, HomeActivity.class); context.getPackageManager().setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); LocalBroadcastManager.getInstance(context) .sendBroadcast(new Intent("com.farmerbb.taskbar.KILL_HOME_ACTIVITY")); }
From source file:townley.stuart.app.android.trekkinly.AlertClass.java
@Override public void onReceive(final Context context, Intent intent) { NotificationItemClass notificationItemClass = new NotificationItemClass(); DataBaseHelper db = new DataBaseHelper(context); db.getWritableDatabase();/*from w w w. ja v a 2 s .co m*/ db.getNotification(notificationItemClass); if (db.notification <= System.currentTimeMillis()) { createNotification(context, "Something is missing!", "Click here for more details!", "Alert"); ComponentName receiver = new ComponentName(context, AlertClass.class); PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); intent = new Intent(context, AlertClass.class); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(PendingIntent.getBroadcast(context.getApplicationContext(), 1, intent, PendingIntent.FLAG_UPDATE_CURRENT)); } else if (db.notification > System.currentTimeMillis()) { intent = new Intent(context, AlertClass.class); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, db.notification, PendingIntent .getBroadcast(context.getApplicationContext(), 1, intent, PendingIntent.FLAG_UPDATE_CURRENT)); } }
From source file:net.eledge.android.europeana.service.receiver.BlogCheckerReceiver.java
public void enableBlogChecker(Context context) { alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, BlogCheckerReceiver.class); blogCheckerIntent = PendingIntent.getBroadcast(context, 0, intent, 0); alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, INTERVAL, INTERVAL, blogCheckerIntent);//w w w .j a v a2 s . c o m ComponentName receiver = new ComponentName(context, BootReceiver.class); PackageManager pm = context.getPackageManager(); if (pm != null) { pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); } }
From source file:com.example.android.powerreceiver.MainActivity.java
@Override protected void onStart() { //Enable the broadcast receiver when the app is visible mPackageManager.setComponentEnabledSetting(mReceiverComponentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); super.onStart(); }
From source file:net.eledge.android.europeana.service.receiver.BlogCheckerReceiver.java
public void disableBlogChecker(Context context) { if (alarmManager != null) { alarmManager.cancel(blogCheckerIntent); }/*ww w .j av a 2 s .c om*/ ComponentName receiver = new ComponentName(context, BootReceiver.class); PackageManager pm = context.getPackageManager(); if (pm != null) { pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } }
From source file:uk.co.ashtonbrsc.intentexplode.Settings.java
public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference == interceptEnabledPreference) { Boolean enabled = (Boolean) newValue; int flag = (enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED); ComponentName component = new ComponentName(Settings.this, Explode.class); getPackageManager().setComponentEnabledSetting(component, flag, PackageManager.DONT_KILL_APP); }//from w w w .j av a2 s.c o m return true; }