本文整理匯總了Java中android.widget.RemoteViews.setPendingIntentTemplate方法的典型用法代碼示例。如果您正苦於以下問題:Java RemoteViews.setPendingIntentTemplate方法的具體用法?Java RemoteViews.setPendingIntentTemplate怎麽用?Java RemoteViews.setPendingIntentTemplate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.RemoteViews
的用法示例。
在下文中一共展示了RemoteViews.setPendingIntentTemplate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateAppWidget
import android.widget.RemoteViews; //導入方法依賴的package包/類
private void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.message_list_widget_layout);
views.setTextViewText(R.id.folder, context.getString(R.string.integrated_inbox_title));
Intent intent = new Intent(context, MessageListWidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
views.setRemoteAdapter(R.id.listView, intent);
PendingIntent viewAction = viewActionTemplatePendingIntent(context);
views.setPendingIntentTemplate(R.id.listView, viewAction);
PendingIntent composeAction = composeActionPendingIntent(context);
views.setOnClickPendingIntent(R.id.new_message, composeAction);
appWidgetManager.updateAppWidget(appWidgetId, views);
}
示例2: onUpdate
import android.widget.RemoteViews; //導入方法依賴的package包/類
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
for (int i = 0; i < appWidgetIds.length; ++i) {
Intent intent = new Intent(context, StackWidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
rv.setRemoteAdapter(appWidgetIds[i], R.id.stack_view, intent);
rv.setEmptyView(R.id.stack_view, R.id.empty_view);
Intent widgetIntent = new Intent(context, StackWidgetProvider.class);
widgetIntent.setAction(StackWidgetProvider.WIDGET_ACTION);
widgetIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
PendingIntent widgetPendingIntent = PendingIntent.getBroadcast(context, 0, widgetIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
rv.setPendingIntentTemplate(R.id.stack_view, widgetPendingIntent);
appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
}
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
示例3: onUpdate
import android.widget.RemoteViews; //導入方法依賴的package包/類
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
for (int appWidgetId : appWidgetIds) {
RemoteViews widgetViews = new RemoteViews(context.getPackageName(), R.layout.news_widget);
Intent svcIntent = new Intent(context, NewsWidgetService.class);
svcIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));
widgetViews.setRemoteAdapter(R.id.newsList, svcIntent);
widgetViews.setEmptyView(R.id.newsList, R.id.emptyMessage);
Intent clickAppIntent = new Intent(context, HomeActivity.class);
Intent clickIntent = new Intent(context, DetailsActivity.class);
PendingIntent appPI = PendingIntent.getActivity(context, 0, clickAppIntent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent clickPI = PendingIntent.getActivity(context, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
widgetViews.setOnClickPendingIntent(R.id.newsTitle, appPI);
widgetViews.setPendingIntentTemplate(R.id.newsList, clickPI);
appWidgetManager.updateAppWidget(appWidgetId, widgetViews);
}
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
開發者ID:vikasdesale,項目名稱:News24x7-news-from-every-part-of-the-world,代碼行數:27,代碼來源:NewsWidgetProvider.java
示例4: updateAppWidget
import android.widget.RemoteViews; //導入方法依賴的package包/類
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
int appWidgetId, Parcelable[] parcelables) {
Log.v(TAG, "updateAppWidget parcelables = " + parcelables.length);
// Construct the RemoteViews object
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.git_hub_journey_widget);
Intent startActivityIntent = new Intent(context, GeneralActivity.class);
PendingIntent startActivityPendingIntent = PendingIntent.getActivity(context, 0, startActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setPendingIntentTemplate(R.id.widget_data_view, startActivityPendingIntent);
Calendar calendar = Calendar.getInstance();
DateFormat dateFormat = Utils.createDateFormatterWithTimeZone(context, context.getString(R.string.add_widget_date_format));
views.setTextViewText(R.id.widget_date, dateFormat.format(calendar.getTime()));
Intent intent = new Intent(context, StackWidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
// When intents are compared, the extras are ignored, so we need to embed the extras
// into the data so that the extras will not be ignored.
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
Bundle bundle = new Bundle();
bundle.putParcelableArray("parcelables", parcelables);
intent.putExtra("bundle", bundle);
views.setRemoteAdapter(R.id.widget_data_view, intent);
views.setEmptyView(R.id.widget_data_view, R.id.empty_view);
// Instruct the widget manager to update the widget
appWidgetManager.updateAppWidget(appWidgetId, views);
}
示例5: updateAppWidgetLayout
import android.widget.RemoteViews; //導入方法依賴的package包/類
private static void updateAppWidgetLayout(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
Filter filter = getFilter(context, appWidgetId);
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.list_widget);
Intent serviceIntent = new Intent(context, ListWidgetService.class);
serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
serviceIntent.putExtra(AppIntent.EXTRA_QUERY_STRING, filter.getQuery());
serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));
// Tell ListView where to get the data from
remoteViews.setRemoteAdapter(R.id.list_widget_list_view, serviceIntent);
remoteViews.setEmptyView(R.id.list_widget_list_view, R.id.list_widget_empty_view);
if (filter.getQuery() == null) {
remoteViews.setTextViewText(R.id.list_widget_empty_view, context.getString(R.string.select_a_filter_long));
} else {
remoteViews.setTextViewText(R.id.list_widget_empty_view, context.getString(R.string.no_notes_found_after_search));
}
// Rows - open note
final Intent onClickIntent = new Intent(context, ListWidgetProvider.class);
onClickIntent.setAction(AppIntent.ACTION_CLICK_LIST_WIDGET);
onClickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
onClickIntent.setData(Uri.parse(onClickIntent.toUri(Intent.URI_INTENT_SCHEME)));
final PendingIntent onClickPendingIntent = PendingIntent.getBroadcast(context, 0,
onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setPendingIntentTemplate(R.id.list_widget_list_view, onClickPendingIntent);
// Plus icon - new note
remoteViews.setOnClickPendingIntent(R.id.list_widget_header_add, ShareActivity.createNewNoteIntent(context, filter));
// Logo - open query
Intent openIntent = Intent.makeRestartActivityTask(new ComponentName(context, MainActivity.class));
openIntent.putExtra(AppIntent.EXTRA_QUERY_STRING, filter.getQuery());
serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));
remoteViews.setOnClickPendingIntent(R.id.list_widget_header_icon, PendingIntent.getActivity(context, 0, openIntent, PendingIntent.FLAG_UPDATE_CURRENT));
Intent filterSelectIntent = new Intent(context, FilterSelectDialogActivity.class);
filterSelectIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
filterSelectIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));
remoteViews.setOnClickPendingIntent(R.id.list_widget_header_bar, PendingIntent.getActivity(context, 0, filterSelectIntent, PendingIntent.FLAG_UPDATE_CURRENT));
remoteViews.setTextViewText(
R.id.list_widget_header_filter,
filter.getName());
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
示例6: onUpdate
import android.widget.RemoteViews; //導入方法依賴的package包/類
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.onUpdate(context, appWidgetManager, appWidgetIds);
for (int appWidgetId : appWidgetIds) {
Intent svcIntent = new Intent(context, WidgetService.class);
svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));
RemoteViews widget = new RemoteViews(context.getPackageName(), R.layout.widget_profile);
widget.setRemoteAdapter(R.id.profile_list, svcIntent);
widget.setPendingIntentTemplate(R.id.profile_list, getPendingIntent(context, LIST_ITEM_CLICK));
appWidgetManager.updateAppWidget(appWidgetId, widget);
}
}
示例7: performUpdate
import android.widget.RemoteViews; //導入方法依賴的package包/類
private void performUpdate(Context context,
AppWidgetManager appWidgetManager, int[] appWidgetIds) {
for (int appWidgetId : appWidgetIds) {
Intent updateIntent = new Intent(context, BookmarkWidgetService.class);
updateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
updateIntent.setData(Uri.parse(updateIntent.toUri(Intent.URI_INTENT_SCHEME)));
int layoutId = shouldShowIconsOnly(appWidgetManager, appWidgetId)
? R.layout.bookmark_widget_icons_only
: R.layout.bookmark_widget;
RemoteViews views = new RemoteViews(context.getPackageName(), layoutId);
views.setRemoteAdapter(R.id.bookmarks_list, updateIntent);
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.bookmarks_list);
Intent ic = new Intent(context, BookmarkWidgetProxy.class);
views.setPendingIntentTemplate(R.id.bookmarks_list,
PendingIntent.getBroadcast(context, 0, ic,
PendingIntent.FLAG_UPDATE_CURRENT));
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}
示例8: updateAppWidget
import android.widget.RemoteViews; //導入方法依賴的package包/類
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
int appWidgetId) {
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.monolith_widget);
// Intent to launch MainActivity
final Intent onItemClick = new Intent(context, MonolithWidget.class);
onItemClick.setAction(ACTION_WIDGET_CLICK);
if (intent != null) {
onItemClick.setData(intent.getData());
Log.e("Content not null", "updateAppWidget: " + intent.getData());
}
PendingIntent onClickPendingIntent = PendingIntent
.getBroadcast(context, 0, onItemClick,
PendingIntent.FLAG_UPDATE_CURRENT);
views.setPendingIntentTemplate(R.id.widget_list,
onClickPendingIntent);
views.setRemoteAdapter(R.id.widget_list,
new Intent(context, WidgetService.class));
views.setEmptyView(R.id.widget_list, R.id.widget_empty);
// Instruct the widget manager to update the widget
appWidgetManager.updateAppWidget(appWidgetId, views);
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.widget_list);
}
示例9: onUpdate
import android.widget.RemoteViews; //導入方法依賴的package包/類
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
// update each of the widgets with the remote adapter
for (int i = 0; i < appWidgetIds.length; ++i) {
// Here we setup the intent which points to the StackViewService which will
// provide the views for this collection.
Intent intent = new Intent(context, StackWidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
// When intents are compared, the extras are ignored, so we need to embed the extras
// into the data so that the extras will not be ignored.
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
rv.setRemoteAdapter(appWidgetIds[i], R.id.stack_view, intent);
// The empty view is displayed when the collection has no items. It should be a sibling
// of the collection view.
rv.setEmptyView(R.id.stack_view, R.id.empty_view);
// Here we setup the a pending intent template. Individuals items of a collection
// cannot setup their own pending intents, instead, the collection as a whole can
// setup a pending intent template, and the individual items can set a fillInIntent
// to create unique before on an item to item basis.
Intent toastIntent = new Intent(context, StackWidgetProvider.class);
toastIntent.setAction(StackWidgetProvider.TOAST_ACTION);
toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
PendingIntent toastPendingIntent = PendingIntent.getBroadcast(context, 0, toastIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
rv.setPendingIntentTemplate(R.id.stack_view, toastPendingIntent);
appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
}
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
示例10: onUpdate
import android.widget.RemoteViews; //導入方法依賴的package包/類
@SuppressLint("PrivateResource")
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
for (int widgetId : appWidgetIds) {
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.buddy_widget_list);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
setRemoteAdapter(context, remoteViews);
} else {
setRemoteAdapterV11(context, remoteViews);
}
Intent clickIntentTemplate = new Intent(context, DetailActivity.class);
PendingIntent pendingIntentTemplate = TaskStackBuilder.create(context)
.addNextIntentWithParentStack(clickIntentTemplate)
.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setPendingIntentTemplate(R.id.widget_list, pendingIntentTemplate);
remoteViews.setEmptyView(R.id.widget_list, R.id.widget_empty);
remoteViews.setContentDescription(R.id.widget_list, context.getString(R.string.widget_cd));
appWidgetManager.updateAppWidget(widgetId, remoteViews);
appWidgetManager.notifyAppWidgetViewDataChanged(widgetId, R.id.widget_list);
}
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
示例11: getIngredientListToUpdate
import android.widget.RemoteViews; //導入方法依賴的package包/類
private static RemoteViews getIngredientListToUpdate(Context context, Recipe recipe) {
RemoteViews ingredientsListView = new RemoteViews(context.getPackageName(), R.layout.ingredients_widget_provider);
Intent remoteAdapterIntent = new Intent(context, RemoteIngredientsListAdapterService.class);
ingredientsListView.setRemoteAdapter(R.id.ingredients_widget_list_view, remoteAdapterIntent);
Intent recipeDetailIntent = new Intent(context, RecipeDetailsActivity.class);
recipeDetailIntent.putExtra(RecipeDetailsActivity.ARGUMENT_RECIPE, recipe);
PendingIntent recipeDetailPendingIntent = PendingIntent.getActivity(context, 0,
recipeDetailIntent, PendingIntent.FLAG_UPDATE_CURRENT);
ingredientsListView.setPendingIntentTemplate(R.id.ingredients_widget_list_view, recipeDetailPendingIntent);
return ingredientsListView;
}
示例12: onUpdate
import android.widget.RemoteViews; //導入方法依賴的package包/類
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.onUpdate(context, appWidgetManager, appWidgetIds);
// Perform this loop procedure for each App Widget that belongs to this provider
for (int appWidgetId : appWidgetIds) {
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_detail);
// Create an Intent to launch MainActivity for example when clicking on the title
Intent intent = new Intent(context, FavoriteMovieActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
rv.setOnClickPendingIntent(R.id.widget, pendingIntent);
Log.d("ArticleWidgetProvider", "onUpdate called: ");
// Set up the collection
setRemoteAdapter(context, rv);
Intent clickIntentTemplate = new Intent(context, DetailActivity.class);
PendingIntent clickPendingIntentTemplate = TaskStackBuilder.create(context)
.addNextIntentWithParentStack(clickIntentTemplate)
.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
rv.setPendingIntentTemplate(R.id.widget_list_new, clickPendingIntentTemplate);
rv.setEmptyView(R.id.widget_list_new, R.id.widget_empty);
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.widget_list_new);
// Tell the AppWidgetManager to perform an update on the current app widget
appWidgetManager.updateAppWidget(appWidgetId, rv);
}
}
示例13: onUpdate
import android.widget.RemoteViews; //導入方法依賴的package包/類
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.onUpdate(context, appWidgetManager, appWidgetIds);
boolean largeScreen = context.getResources().getBoolean(R.bool.large_layout);
for (int appWidgetId : appWidgetIds) {
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget);
// WidgetListService intent for populating collection views.
Intent collectionIntent = new Intent(context, WidgetListService.class);
rv.setRemoteAdapter(R.id.widget_list, collectionIntent);
rv.setEmptyView(R.id.widget_list, R.id.widget_empty);
// Intent for opening the main app from the widget title.
Intent itemReaperIntent = new Intent(context, ItemsActivity.class);
PendingIntent itemReaperPendingIntent = PendingIntent.getActivity(context, 0,
itemReaperIntent, 0);
rv.setOnClickPendingIntent(R.id.widget_title, itemReaperPendingIntent);
// Intent for adding an item when clicking the add item button.
Intent addItemIntent = largeScreen
? new Intent(context, ItemsActivity.class)
: new Intent(context, EditItemActivity.class);
addItemIntent.putExtra(EXTRA_EDIT_NEW_ITEM, true);
addItemIntent.setAction(ACTION_EDIT_NEW_ITEM);
PendingIntent addItemPendingIntent = TaskStackBuilder.create(context)
.addNextIntentWithParentStack(addItemIntent)
.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
rv.setOnClickPendingIntent(R.id.widget_add_item, addItemPendingIntent);
// Collection for ItemDetailsActivity intent when opening individual list item.
Intent clickIntentTemplate = largeScreen
? new Intent(context, ItemsActivity.class)
: new Intent(context, ItemDetailsActivity.class);
PendingIntent clickPendingIntentTemplate = TaskStackBuilder.create(context)
.addNextIntentWithParentStack(clickIntentTemplate)
.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
rv.setPendingIntentTemplate(R.id.widget_list, clickPendingIntentTemplate);
appWidgetManager.updateAppWidget(appWidgetId, rv);
}
}
示例14: onUpdate
import android.widget.RemoteViews; //導入方法依賴的package包/類
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
LOGD(TAG, "updating app widget");
final boolean isAuthenticated = AccountUtils.hasActiveAccount(context);
for (int appWidgetId : appWidgetIds) {
// Specify the service to provide data for the collection widget. Note that we need to
// embed the appWidgetId via the data otherwise it will be ignored.
final Intent intent = new Intent(context, ScheduleWidgetRemoteViewsService.class)
.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
final RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget);
rv.setRemoteAdapter(R.id.widget_schedule_list, intent);
// Set the empty view to be displayed if the collection is empty. It must be a sibling
// view of the collection view.
rv.setEmptyView(R.id.widget_schedule_list, android.R.id.empty);
LOGD(TAG, "setting widget empty view");
rv.setTextViewText(android.R.id.empty, context.getResources().getString(isAuthenticated
? R.string.empty_widget_text
: R.string.empty_widget_text_signed_out));
final PendingIntent refreshPendingIntent = PendingIntent.getBroadcast(context, 0,
getRefreshBroadcastIntent(context, true), PendingIntent.FLAG_UPDATE_CURRENT);
rv.setOnClickPendingIntent(R.id.widget_refresh_button, refreshPendingIntent);
final Intent onClickIntent = TaskStackBuilderProxyActivity.getTemplate(context);
final PendingIntent onClickPendingIntent = PendingIntent.getActivity(context, 0,
onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
rv.setPendingIntentTemplate(R.id.widget_schedule_list, onClickPendingIntent);
final Intent openAppIntent = new Intent(context, MyScheduleActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
final PendingIntent openAppPendingIntent = PendingIntent.getActivity(context, 0,
openAppIntent, PendingIntent.FLAG_UPDATE_CURRENT);
rv.setOnClickPendingIntent(R.id.widget_logo, openAppPendingIntent);
appWidgetManager.updateAppWidget(appWidgetId, rv);
}
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
示例15: onUpdate
import android.widget.RemoteViews; //導入方法依賴的package包/類
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
final int N = appWidgetIds.length;
// Perform this loop procedure for each App Widget that belongs to this provider
for (int i = 0; i < N; i++) {
int appWidgetId = appWidgetIds[i];
// Get the layout for the App Widget and attach an on-click listener to the button
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
SharedPreferences sharedPreferences = context.getSharedPreferences(
"" + appWidgetIds[i], Context.MODE_PRIVATE);
String directory = sharedPreferences.getString(WIDGET_PATH, AppSettings.get().getNotebookDirectoryAsStr());
Intent newDocumentIntent = new Intent(context, DocumentActivity.class)
.putExtra(DocumentIO.EXTRA_PATH, new File(directory))
.putExtra(DocumentIO.EXTRA_PATH_IS_FOLDER, true);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, newDocumentIntent, 0);
views.setOnClickPendingIntent(R.id.widget_new_note, pendingIntent);
Intent goToMain = new Intent(context, MainActivity.class);
PendingIntent goToMainPendingIntent = PendingIntent.getActivity(context, 0, goToMain, 0);
views.setOnClickPendingIntent(R.id.widget_header, goToMainPendingIntent);
// ListView
Intent notesListIntent = new Intent(context, FilesWidgetService.class);
notesListIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
notesListIntent.putExtra(DocumentIO.EXTRA_PATH, new File(directory));
notesListIntent.putExtra(DocumentIO.EXTRA_PATH_IS_FOLDER, true);
notesListIntent.setData(Uri.parse(notesListIntent.toUri(Intent.URI_INTENT_SCHEME)));
views.setEmptyView(R.id.widget_list_container, R.id.widget_empty_hint);
views.setRemoteAdapter(R.id.widget_notes_list, notesListIntent);
Intent openNoteIntent = new Intent(context, DocumentActivity.class).setAction(Intent.ACTION_EDIT);
PendingIntent openNotePendingIntent = PendingIntent.getActivity(context, 0,
openNoteIntent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setPendingIntentTemplate(R.id.widget_notes_list, openNotePendingIntent);
// Tell the AppWidgetManager to perform an update on the current app widget
appWidgetManager.updateAppWidget(appWidgetId, views);
}
super.onUpdate(context, appWidgetManager, appWidgetIds);
}