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.appsaur.tarucassist.AutomuteAlarmReceiver.java
public void cancelAlarm(Context context, int ID) { mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); // Cancel Alarm using Reminder ID mPendingIntent = PendingIntent.getBroadcast(context, ID, new Intent(context, AutomuteAlarmReceiver.class), 0);/*from w w w . java2 s . c om*/ mAlarmManager.cancel(mPendingIntent); // Disable alarm ComponentName receiver = new ComponentName(context, BootReceiver.class); PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); }
From source file:org.traccar.client.MainFragment.java
private void removeLauncherIcon() { String className = MainActivity.class.getCanonicalName().replace(".MainActivity", ".Launcher"); ComponentName componentName = new ComponentName(getActivity().getPackageName(), className); PackageManager packageManager = getActivity().getPackageManager(); if (packageManager .getComponentEnabledSetting(componentName) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED) { packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setMessage(getString(R.string.hidden_alert)); builder.setPositiveButton(android.R.string.ok, null); builder.show();// w w w . j a va 2 s . c o m } }
From source file:co.carlosandresjimenez.android.gotit.notification.AlarmReceiver.java
/** * Cancels the alarm.//from ww w .j av a2 s .com * * @param context */ public void cancelAlarm(Context context) { // If the alarm has been set, cancel it. if (alarmMgr != null) { alarmIntent.cancel(); alarmMgr.cancel(alarmIntent); } mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(NOTIFICATION_ID); ComponentName receiver = new ComponentName(context, BootReceiver.class); PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); }
From source file:ru.glesik.wifireminders.AlarmService.java
public void stopAlarm() { AlarmManager alarmManager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(this, AlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0); alarmManager.cancel(pendingIntent);//w w w . j a v a 2 s . c o m // Disable boot receiver ComponentName receiver = new ComponentName(this, BootReceiver.class); PackageManager pm = this.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); }
From source file:co.edu.uniajc.vtf.ar.ARViewActivity.java
@Override protected void onResume() { super.onResume(); ComponentName loComponent = new ComponentName(this, NetworkStatusReceiver.class); this.getPackageManager().setComponentEnabledSetting(loComponent, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); this.loadPosition(); if (this.architectView != null) { this.architectView.onResume(); }/*w ww. j ava2 s .c om*/ }
From source file:com.appsaur.tarucassist.AlarmReceiver.java
public void setRepeatAlarm(Context context, Calendar calendar, int ID, long RepeatTime) { mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); // Put Reminder ID in Intent Extra Intent intent = new Intent(context, AlarmReceiver.class); intent.putExtra(BaseActivity.EXTRA_REMINDER_ID, Integer.toString(ID)); mPendingIntent = PendingIntent.getBroadcast(context, ID, intent, PendingIntent.FLAG_CANCEL_CURRENT); // Calculate notification timein Calendar c = Calendar.getInstance(); long currentTime = c.getTimeInMillis(); long diffTime = calendar.getTimeInMillis() - currentTime; // Start alarm using initial notification time and repeat interval time mAlarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + diffTime, RepeatTime, mPendingIntent); // Restart alarm if device is rebooted ComponentName receiver = new ComponentName(context, BootReceiver.class); PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); }
From source file:townley.stuart.app.android.trekkinly.Notification_picker_class.java
public void setNotification() { NotificationItemClass notificationItemClass = new NotificationItemClass(); DataBaseHelper db = new DataBaseHelper(getActivity()); db.getWritableDatabase();/*from ww w .ja v a 2s . co m*/ db.addNotification(notificationItemClass); db.upDateDataBaseNotification(notificationItemClass); db.getNotification(notificationItemClass); if (db.notification <= 0) { Toast.makeText(getActivity(), "Please set a time for the notification", Toast.LENGTH_SHORT).show(); } else { ComponentName receiver = new ComponentName(getActivity(), AlertClass.class); PackageManager pm = getActivity().getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); Intent intent = new Intent(getActivity(), AlertClass.class); AlarmManager alarmManager = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, db.notification, PendingIntent.getBroadcast( getActivity().getApplicationContext(), 1, intent, PendingIntent.FLAG_UPDATE_CURRENT)); Toast.makeText(getActivity(), "Notification issued", Toast.LENGTH_SHORT).show(); Log.d("Trekkinly", "AlarmNotification Called"); } }
From source file:com.soft.pushsender.DemoActivity.java
private void enPush() { //Enable push notifications ComponentName receiver = new ComponentName(context, GcmBroadcastReceiver.class); PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); }
From source file:com.github.michalbednarski.intentslab.StartActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_settings: startActivity(new Intent(this, PrefsActivity.class)); return true; case R.id.interception: { final PackageManager packageManager = getPackageManager(); boolean enable = packageManager.getComponentEnabledSetting( mInterceptActivityComponentName) != PackageManager.COMPONENT_ENABLED_STATE_ENABLED; packageManager/*from ww w.ja va2 s . c o m*/ .setComponentEnabledSetting(mInterceptActivityComponentName, enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); Toast.makeText(this, enable ? getString(R.string.interception_enabled) : getString(R.string.interception_disabled), Toast.LENGTH_SHORT).show(); ActivityCompat.invalidateOptionsMenu(this); return true; } case R.id.system_services: (new SystemServicesDialog()).show(getSupportFragmentManager(), "systemServices"); return true; case R.id.provider_lab: startActivity(new Intent(StartActivity.this, AdvancedQueryActivity.class)); return true; } return false; }
From source file:co.edu.uniajc.vtf.ar.ARViewActivity.java
@Override protected void onPause() { super.onPause(); ComponentName loComponent = new ComponentName(this, NetworkStatusReceiver.class); this.getPackageManager().setComponentEnabledSetting(loComponent, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); LocationServices.FusedLocationApi.removeLocationUpdates(coGoogleApiClient, this); if (this.architectView != null) { this.architectView.onPause(); }//from w ww . j ava 2 s. c o m }