Java Code Examples for android.content.Intent.cloneFilter()

The following are Jave code examples for showing how to use cloneFilter() of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: aos-Video   File:   View Source Code Vote up 7 votes
private void replacePreviousDelayedAlarm(String action, int delay) {
    PendingIntent pendingIntent;

    // Cancel any previous alarm set for a content changed event
    if (mLastContentChangedIntent != null) {
        pendingIntent = PendingIntent.getBroadcast(mContext, 0, mLastContentChangedIntent, 0);

    // Set a new delayed alarm and save a copy of the intent to send in case we want to cancel it later
    Intent intent = new Intent(mContext, WidgetProviderVideo.class);
    intent.setData(Uri.parse(String.valueOf(SystemClock.elapsedRealtime())));   // Fill data with a dummy value to avoid the "extra beeing ignored" optimization of the PendingIntent
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
    mLastContentChangedIntent = intent.cloneFilter();                           // This is enough to identify the intent
    pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
    mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + delay, pendingIntent);