本文整理匯總了Java中android.content.Intent.cloneFilter方法的典型用法代碼示例。如果您正苦於以下問題:Java Intent.cloneFilter方法的具體用法?Java Intent.cloneFilter怎麽用?Java Intent.cloneFilter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.content.Intent
的用法示例。
在下文中一共展示了Intent.cloneFilter方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: replacePreviousDelayedAlarm
import android.content.Intent; //導入方法依賴的package包/類
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);
mAlarmManager.cancel(pendingIntent);
}
// 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.setAction(action);
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);
}