use of android.app.PendingIntent in project platform_frameworks_base by android.
the class AudioManager method registerMediaButtonEventReceiver.
//====================================================================
// Remote Control
/**
* Register a component to be the sole receiver of MEDIA_BUTTON intents.
* @param eventReceiver identifier of a {@link android.content.BroadcastReceiver}
* that will receive the media button intent. This broadcast receiver must be declared
* in the application manifest. The package of the component must match that of
* the context you're registering from.
* @deprecated Use {@link MediaSession#setMediaButtonReceiver(PendingIntent)} instead.
*/
@Deprecated
public void registerMediaButtonEventReceiver(ComponentName eventReceiver) {
if (eventReceiver == null) {
return;
}
if (!eventReceiver.getPackageName().equals(getContext().getPackageName())) {
Log.e(TAG, "registerMediaButtonEventReceiver() error: " + "receiver and context package names don't match");
return;
}
// construct a PendingIntent for the media button and register it
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
// the associated intent will be handled by the component being registered
mediaButtonIntent.setComponent(eventReceiver);
PendingIntent pi = PendingIntent.getBroadcast(getContext(), 0, /*requestCode, ignored*/
mediaButtonIntent, 0);
registerMediaButtonIntent(pi, eventReceiver);
}
use of android.app.PendingIntent in project platform_frameworks_base by android.
the class CarrierDefaultReceiverTest method testOnReceiveRedirection.
@Test
public void testOnReceiveRedirection() {
// carrier action idx list includes 4(portal notification) & 1(disable metered APNs)
// upon redirection signal
PersistableBundle b = new PersistableBundle();
b.putStringArray(CarrierConfigManager.KEY_CARRIER_DEFAULT_ACTIONS_ON_REDIRECTION_STRING_ARRAY, new String[] { "4,1" });
doReturn(b).when(mCarrierConfigMgr).getConfig();
Intent intent = new Intent(TelephonyIntents.ACTION_CARRIER_SIGNAL_REDIRECTED);
intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Rlog.d(TAG, "OnReceive redirection intent");
mReceiver.onReceive(mContext, intent);
mContext.waitForMs(100);
Rlog.d(TAG, "verify carrier action: showPortalNotification");
verify(mNotificationMgr, times(1)).notify(mString.capture(), mInt.capture(), mNotification.capture());
assertEquals(PORTAL_NOTIFICATION_ID, (int) mInt.getValue());
assertEquals(PORTAL_NOTIFICATION_TAG, mString.getValue());
PendingIntent pendingIntent = mNotification.getValue().contentIntent;
assertNotNull(pendingIntent);
Rlog.d(TAG, "verify carrier action: disable all metered apns");
verify(mTelephonyMgr).carrierActionSetMeteredApnsEnabled(eq(subId), eq(false));
}
use of android.app.PendingIntent in project platform_frameworks_base by android.
the class CarrierActionUtils method onShowCaptivePortalNotification.
private static void onShowCaptivePortalNotification(Intent intent, Context context) {
logd("onShowCaptivePortalNotification");
final NotificationManager notificationMgr = context.getSystemService(NotificationManager.class);
Intent portalIntent = new Intent(context, CaptivePortalLoginActivity.class);
portalIntent.putExtras(intent);
portalIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, portalIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = getNotification(context, R.string.portal_notification_id, R.string.portal_notification_detail, pendingIntent);
try {
notificationMgr.notify(PORTAL_NOTIFICATION_TAG, PORTAL_NOTIFICATION_ID, notification);
} catch (NullPointerException npe) {
loge("setNotificationVisible: " + npe);
}
}
use of android.app.PendingIntent in project platform_frameworks_base by android.
the class MainActivity method sendNotification.
private void sendNotification(int count) {
Notification.Builder builder = new Notification.Builder(this).setContentTitle(String.format("%s OSU available", count)).setContentText("Choose one to connect").setSmallIcon(android.R.drawable.ic_dialog_info).setAutoCancel(false);
Intent resultIntent = new Intent(this, MainActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(resultPendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID, builder.build());
}
use of android.app.PendingIntent in project platform_frameworks_base by android.
the class BugreportProgressService method newCancelIntent.
/**
* Creates a {@link PendingIntent} for a notification action used to cancel a bugreport.
*/
private static PendingIntent newCancelIntent(Context context, BugreportInfo info) {
final Intent intent = new Intent(INTENT_BUGREPORT_CANCEL);
intent.setClass(context, BugreportProgressService.class);
intent.putExtra(EXTRA_ID, info.id);
return PendingIntent.getService(context, info.id, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
Aggregations