List of usage examples for android.content Intent FLAG_RECEIVER_FOREGROUND
int FLAG_RECEIVER_FOREGROUND
To view the source code for android.content Intent FLAG_RECEIVER_FOREGROUND.
Click Source Link
From source file:com.gzsll.downloads.DownloadNotification.java
private PendingIntent getPendingContentIntent(NotificationItem item) { Intent intent = new Intent(); intent.setAction(Constants.ACTION_LIST); intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND); intent.setClassName(mContext.getPackageName(), DownloadReceiver.class.getName()); intent.setData(ContentUris.withAppendedId(Downloads.ALL_DOWNLOADS_CONTENT_URI, item.mId)); intent.putExtra("multiple", item.mTitleCount > 1); return PendingIntent.getBroadcast(mContext, 0, intent, 0); }
From source file:me.piebridge.prevent.ui.PreventActivity.java
private void retrievePrevents() { Intent intent = new Intent(); intent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND); intent.setAction(PreventIntent.ACTION_GET_PACKAGES); intent.setData(Uri.fromParts(PreventIntent.SCHEME, getPackageName(), null)); UILog.i("sending get prevent packages broadcast"); sendOrderedBroadcast(intent, PreventIntent.PERMISSION_SYSTEM, receiver, mHandler, 0, null, null); }
From source file:me.piebridge.prevent.ui.PreventActivity.java
private void retrieveRunning() { Intent intent = new Intent(); intent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND); intent.setAction(PreventIntent.ACTION_GET_PROCESSES); intent.setData(Uri.fromParts(PreventIntent.SCHEME, getPackageName(), null)); UILog.i("sending get processes broadcast"); sendOrderedBroadcast(intent, PreventIntent.PERMISSION_SYSTEM, receiver, mHandler, 0, null, null); }
From source file:com.android.managedprovisioning.DeviceOwnerProvisioningActivity.java
private void error(int dialogMessage, boolean resetRequired) { AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this).setTitle(R.string.provisioning_error_title) .setMessage(dialogMessage).setCancelable(false); if (resetRequired) { alertBuilder.setPositiveButton(R.string.device_owner_error_reset, new DialogInterface.OnClickListener() { @Override//from ww w . j ava 2s .c o m public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); // Factory reset the device. Intent intent = new Intent(Intent.ACTION_MASTER_CLEAR); intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); intent.putExtra(Intent.EXTRA_REASON, "DeviceOwnerProvisioningActivity.error()"); sendBroadcast(intent); stopService(new Intent(DeviceOwnerProvisioningActivity.this, DeviceOwnerProvisioningService.class)); setResult(RESULT_CANCELED); finish(); } }); } else { alertBuilder.setPositiveButton(R.string.device_owner_error_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); // Close activity. stopService( new Intent(DeviceOwnerProvisioningActivity.this, DeviceOwnerProvisioningService.class)); setResult(RESULT_CANCELED); finish(); } }); } alertBuilder.show(); }
From source file:me.piebridge.prevent.ui.PreventActivity.java
private boolean requestLog() { if (getExternalCacheDir() != null) { Intent intent = new Intent(); intent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND); intent.setAction(PreventIntent.ACTION_SYSTEM_LOG); intent.setData(Uri.fromParts(PreventIntent.SCHEME, getPackageName(), null)); UILog.i("sending request log broadcast"); showProcessDialog(R.string.retrieving); sendOrderedBroadcast(intent, PreventIntent.PERMISSION_SYSTEM, receiver, mHandler, 0, null, null); }//from w w w . ja v a2s . co m return false; }
From source file:com.android.deskclock.timer.TimerReceiver.java
private void updateNextTimesup(Context context) { TimerObj t = getNextRunningTimer(mTimers, false, Utils.getTimeNow()); long nextTimesup = (t == null) ? -1 : t.getTimesupTime(); int timerId = (t == null) ? -1 : t.mTimerId; Intent intent = new Intent(); intent.setAction(Timers.TIMES_UP);//from w w w . j ava2 s. c o m intent.setClass(context, TimerReceiver.class); // Time-critical, should be foreground intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); if (!mTimers.isEmpty()) { intent.putExtra(Timers.TIMER_INTENT_EXTRA, timerId); } AlarmManager mngr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); PendingIntent p = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT); if (t != null) { if (Utils.isKitKatOrLater()) { mngr.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextTimesup, p); } else { mngr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextTimesup, p); } if (Timers.LOGGING) { Log.d(TAG, "Setting times up to " + nextTimesup); } } else { // if no timer is found Pending Intents should be canceled // to keep the internal state consistent with the UI mngr.cancel(p); p.cancel(); if (Timers.LOGGING) { Log.v(TAG, "no next times up"); } } }
From source file:me.piebridge.prevent.ui.UserGuideActivity.java
private void requestLicense() { if (TextUtils.isEmpty(LicenseUtils.getLicenseName(this))) { Intent intent = new Intent(PreventIntent.ACTION_CHECK_LICENSE, Uri.fromParts(PreventIntent.SCHEME, getPackageName(), null)); intent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND); sendOrderedBroadcast(intent, PreventIntent.PERMISSION_SYSTEM, new BroadcastReceiver() { @Override/*from w w w . j a va2 s .co m*/ public void onReceive(Context context, Intent intent) { if (PreventIntent.ACTION_CHECK_LICENSE.equals(intent.getAction()) && getResultCode() != 1) { request = LicenseUtils.requestLicense(UserGuideActivity.this, null, getResultData()); } } }, null, 0, null, null); } }
From source file:com.betterAlarm.deskclock.timer.TimerFragment.java
private void updateTimerState(TimerObj t, String action) { if (Timers.DELETE_TIMER.equals(action)) { mAdapter.deleteTimer(t.mTimerId); if (mAdapter.getCount() == 0) { mSetupView.reset();//from w w w. j ava 2 s . c om goToSetUpView(); } } else { t.writeToSharedPref(mPrefs); } final Intent i = new Intent(); i.setAction(action); i.putExtra(Timers.TIMER_INTENT_EXTRA, t.mTimerId); // Make sure the receiver is getting the intent ASAP. i.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); getActivity().sendBroadcast(i); }
From source file:me.piebridge.prevent.ui.UserGuideActivity.java
private void retrieveInfo() { Intent intent = new Intent(); intent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND); intent.setAction(PreventIntent.ACTION_GET_INFO); intent.setData(Uri.fromParts(PreventIntent.SCHEME, getPackageName(), null)); UILog.i("sending get info broadcast"); if (receiver == null) { receiver = new HookReceiver(); }//from w w w . jav a 2 s. co m sendOrderedBroadcast(intent, PreventIntent.PERMISSION_SYSTEM, receiver, null, 0, null, null); }
From source file:com.wojtechnology.sunami.TheBrain.java
private void setNotification(FireMixtape song) { if (mPlaying == null) { stopForeground(true);/*from w w w. ja v a2s .c om*/ return; } setMetadata(song); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Notification is created in setMetadata return; } if (mNotification == null || mNotificationView == null) { Intent notificationIntent = new Intent(this, MainActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 1, notificationIntent, 0); mNotificationView = new RemoteViews(getPackageName(), R.layout.notification); mNotification = new Notification.Builder(this).setSmallIcon(R.mipmap.sunaminotif) .setContentIntent(pendingIntent).setContent(mNotificationView).build(); } Intent servicePlayIntent = new Intent(getApplicationContext(), TheBrain.class); servicePlayIntent.setAction(TheBrain.TOGGLE_PLAY); servicePlayIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); PendingIntent pendingPlayIntent = PendingIntent.getService(mContext, 1, servicePlayIntent, 0); Intent serviceNextIntent = new Intent(getApplicationContext(), TheBrain.class); serviceNextIntent.setAction(TheBrain.PLAY_NEXT); serviceNextIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); PendingIntent pendingNextIntent = PendingIntent.getService(mContext, 1, serviceNextIntent, 0); Intent serviceStopIntent = new Intent(getApplicationContext(), TheBrain.class); serviceStopIntent.setAction(TheBrain.PLAY_STOP); serviceStopIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); PendingIntent pendingStopIntent = PendingIntent.getService(mContext, 1, serviceStopIntent, 0); mNotificationView.setTextViewText(R.id.notif_title, song.title); mNotificationView.setTextViewText(R.id.notif_artist, song.artist); mNotificationView.setOnClickPendingIntent(R.id.play_notif_button, pendingPlayIntent); mNotificationView.setOnClickPendingIntent(R.id.next_notif_button, pendingNextIntent); mNotificationView.setOnClickPendingIntent(R.id.close_notif_button, pendingStopIntent); setNotificationStatus(true); }