use of android.app.PendingIntent in project cw-omnibus by commonsguy.
the class MainActivity method notifyMe.
public void notifyMe(View v) {
Intent i = new Intent(this, AlarmReceiver.class).putExtra(AlarmReceiver.EXTRA_TYPE, type.getSelectedItemPosition());
PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager mgr = (AlarmManager) getSystemService(ALARM_SERVICE);
mgr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + (1000 * delay.getProgress()), pi);
}
use of android.app.PendingIntent in project cw-omnibus by commonsguy.
the class MainActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent i = new Intent(this, RemoteInputReceiver.class);
PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
RemoteInput remoteInput = new RemoteInput.Builder(RemoteInputReceiver.EXTRA_INPUT).setLabel(getString(R.string.talk)).build();
NotificationCompat.Action remoteAction = new NotificationCompat.Action.Builder(android.R.drawable.ic_btn_speak_now, getString(R.string.talk), pi).addRemoteInput(remoteInput).build();
NotificationCompat.Builder builder = RemoteInputReceiver.buildNotificationBase(this).addAction(remoteAction);
NotificationManagerCompat.from(this).notify(RemoteInputReceiver.NOTIFY_ID, builder.build());
finish();
}
use of android.app.PendingIntent in project android-job by evernote.
the class JobProxy14 method plantPeriodic.
@Override
public void plantPeriodic(JobRequest request) {
PendingIntent pendingIntent = getPendingIntent(request, true);
AlarmManager alarmManager = getAlarmManager();
if (alarmManager != null) {
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + request.getIntervalMs(), request.getIntervalMs(), pendingIntent);
}
mCat.d("Scheduled repeating alarm, %s, interval %s", request, JobUtil.timeToString(request.getIntervalMs()));
}
use of android.app.PendingIntent in project android-job by evernote.
the class JobProxy14 method plantPeriodicFlexSupport.
@Override
public void plantPeriodicFlexSupport(JobRequest request) {
PendingIntent pendingIntent = getPendingIntent(request, false);
AlarmManager alarmManager = getAlarmManager();
if (alarmManager == null) {
return;
}
try {
plantOneOffFlexSupport(request, alarmManager, pendingIntent);
} catch (Exception e) {
// https://gist.github.com/vRallev/621b0b76a14ddde8691c
mCat.e(e);
}
}
use of android.app.PendingIntent in project android_frameworks_base by ParanoidAndroid.
the class TransportControlView method sendMediaButtonClick.
private void sendMediaButtonClick(int keyCode) {
if (mClientIntent == null) {
// Shouldn't be possible because this view should be hidden in this case.
Log.e(TAG, "sendMediaButtonClick(): No client is currently registered");
return;
}
// use the registered PendingIntent that will be processed by the registered
// media button event receiver, which is the component of mClientIntent
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);
Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
intent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
try {
mClientIntent.send(getContext(), 0, intent);
} catch (CanceledException e) {
Log.e(TAG, "Error sending intent for media button down: " + e);
e.printStackTrace();
}
keyEvent = new KeyEvent(KeyEvent.ACTION_UP, keyCode);
intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
intent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
try {
mClientIntent.send(getContext(), 0, intent);
} catch (CanceledException e) {
Log.e(TAG, "Error sending intent for media button up: " + e);
e.printStackTrace();
}
}
Aggregations