Search in sources :

Example 26 with PendingIntent

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);
}
Also used : AlarmManager(android.app.AlarmManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 27 with PendingIntent

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();
}
Also used : RemoteInput(android.support.v4.app.RemoteInput) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 28 with PendingIntent

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()));
}
Also used : AlarmManager(android.app.AlarmManager) PendingIntent(android.app.PendingIntent)

Example 29 with PendingIntent

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);
    }
}
Also used : AlarmManager(android.app.AlarmManager) PendingIntent(android.app.PendingIntent)

Example 30 with PendingIntent

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();
    }
}
Also used : KeyEvent(android.view.KeyEvent) CanceledException(android.app.PendingIntent.CanceledException) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Aggregations

PendingIntent (android.app.PendingIntent)1208 Intent (android.content.Intent)1010 Notification (android.app.Notification)222 NotificationCompat (android.support.v4.app.NotificationCompat)167 AlarmManager (android.app.AlarmManager)149 NotificationManager (android.app.NotificationManager)148 Bundle (android.os.Bundle)75 RemoteViews (android.widget.RemoteViews)67 RemoteException (android.os.RemoteException)64 Resources (android.content.res.Resources)62 Bitmap (android.graphics.Bitmap)61 Context (android.content.Context)60 ComponentName (android.content.ComponentName)55 Test (org.junit.Test)44 Uri (android.net.Uri)42 IntentFilter (android.content.IntentFilter)41 SharedPreferences (android.content.SharedPreferences)36 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)33 UserHandle (android.os.UserHandle)31 ArrayList (java.util.ArrayList)30