本文整理匯總了Java中android.widget.RemoteViews.setRemoteAdapter方法的典型用法代碼示例。如果您正苦於以下問題:Java RemoteViews.setRemoteAdapter方法的具體用法?Java RemoteViews.setRemoteAdapter怎麽用?Java RemoteViews.setRemoteAdapter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.RemoteViews
的用法示例。
在下文中一共展示了RemoteViews.setRemoteAdapter方法的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: updateAppWidget
import android.widget.RemoteViews; //導入方法依賴的package包/類
private static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.schedule_daily_widget);
Intent intent = new Intent(context, ScheduleDailyService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
views.setRemoteAdapter(appWidgetId, R.id.list_item, intent);
views.setViewVisibility(R.id.sync_instruction, IS_NOT_READY_YET ? TextView.VISIBLE : TextView.GONE);
Intent launchMain = new Intent(context, MainActivity.class);
PendingIntent pendingMainIntent = PendingIntent.getActivity(context, 0, launchMain, 0);
views.setOnClickPendingIntent(R.id.widget_daily, pendingMainIntent);
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.list_item);
appWidgetManager.updateAppWidget(appWidgetId, views);
}
示例3: updateWidgetListView
import android.widget.RemoteViews; //導入方法依賴的package包/類
private RemoteViews updateWidgetListView(Context context, int id) {
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.launcher_list_widget);
Intent intent = new Intent(context, AppWidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
remoteViews.setRemoteAdapter(R.id.listViewWidget, intent);
remoteViews.setEmptyView(R.id.listViewWidget, R.id.emptyView);
Intent tempIntent = new Intent(context, PackageDetailsActivity.class);
tempIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
remoteViews.setPendingIntentTemplate(R.id.listViewWidget,
PendingIntent.getActivity(context, 0, tempIntent, PendingIntent.FLAG_CANCEL_CURRENT));
return remoteViews;
}
示例4: 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);
}
示例5: 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
示例6: 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);
}
示例7: updateAppWidget
import android.widget.RemoteViews; //導入方法依賴的package包/類
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
int appWidgetId) {
long recipeId = RecipeIngredientsWidgetConfigureActivity.loadIdPref(context, appWidgetId);
String recipeName = RecipeIngredientsWidgetConfigureActivity.loadTitlePref(context, appWidgetId);
// Construct the RemoteViews object
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.recipe_ingredients_widget);
Intent intent = new Intent(context, RecipeIngredientsWidgetService.class);
intent.putExtra("RECIPE_ID", recipeId);
views.setRemoteAdapter(R.id.gv_widget, intent);
Intent detailIntent = new Intent(context, DetailActivity.class);
detailIntent.putExtra("RECIPE_ID", recipeId);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, detailIntent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.ll_widget, pendingIntent);
views.setTextViewText(R.id.tv_recipe_widget_name, recipeName);
// Instruct the widget manager to update the widget
appWidgetManager.updateAppWidget(appWidgetId, views);
}
示例8: 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);
}
}
示例9: 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);
}
示例10: updateAppWidget
import android.widget.RemoteViews; //導入方法依賴的package包/類
public static void updateAppWidget(AppWidgetManager manager, Context context, int appWidgetId, String repositoryName, String uuid) {
RemoteViews views = createRemoteViews(context, appWidgetId, repositoryName, uuid);
// Service intent, sent to WidgetListFactory
Intent svcIntent = new Intent(context, WidgetService.class);
svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
svcIntent.putExtra(KEY_TODO_LIST, repositoryName);
svcIntent.putExtra(KEY_UUID, uuid);
svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));
views.setRemoteAdapter(R.id.widget_list_view, svcIntent);
manager.updateAppWidget(appWidgetId, views);
}
示例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) {
// update each of the app widgets with the remote adapter
for (int i = 0; i < appWidgetIds.length; ++i) {
// Set up the intent that starts the StackViewService, which will
// provide the views for this collection.
Intent intent = new Intent(context, LeaderboardWidgetService.class);
// Add the app widget ID to the intent extras.
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
// Instantiate the RemoteViews object for the app widget layout.
RemoteViews rv =
new RemoteViews(context.getPackageName(), R.layout.widget_leaderboard);
// Set up the RemoteViews object to use a RemoteViews adapter.
// This adapter connects
// to a RemoteViewsService through the specified intent.
// This is how you populate the data.
rv.setRemoteAdapter(R.id.list_widget_leaderboard, intent);
// The empty view is displayed when the collection has no items.
// It should be in the same layout used to instantiate the RemoteViews
// object above.
rv.setEmptyView(R.id.list_widget_leaderboard, R.id.empty_view);
appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
}
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
示例13: 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++) {
Log.d("WidgetHandler","loop executing");
Intent svcIntent=new Intent(context, WidgetService.class);
svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));
RemoteViews widget=new RemoteViews(context.getPackageName(),
R.layout.widget_layout);
widget.setRemoteAdapter(appWidgetIds[i], R.id.MainListView,
svcIntent);
Intent clickIntent=new Intent(context, TaskViewActivity.class);
PendingIntent clickPI=PendingIntent
.getActivity(context, 0,
clickIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
widget.setPendingIntentTemplate(R.id.MainListView, clickPI);
appWidgetManager.updateAppWidget(appWidgetIds[i], widget);
/*int appWidgetId = appWidgetIds[i];
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
SQLiteDatabase sqlDB=context.openOrCreateDatabase("dbKartik12#4",context.MODE_PRIVATE, null);
sqlDB.execSQL("CREATE TABLE IF NOT EXISTS ToDoList(Task varchar(50) PRIMARY KEY,Status char(5))");
/**
* This section retrieves data from DB and adds it to ArrayList @existingTasks
Cursor existingTasks=sqlDB.rawQuery("SELECT * FROM ToDoList",null);
mainList=new ArrayList<TaskItem>();
if(existingTasks!=null){
if(existingTasks.moveToFirst()){
do{
mainList.add( new TaskItem( existingTasks.getString( existingTasks.getColumnIndex("Task")) , Boolean.valueOf( existingTasks.getString(existingTasks.getColumnIndex("Status")) ) ) );
}while (existingTasks.moveToNext());
}
}
ListView mainListView=(ListView) views.findViewById(R.id.MainListView);
ArrayAdapter ad=new TaskAdapter((ArrayList) mainList,context,sqlDB);
if(mainListView!=null){
mainListView.setAdapter(ad);
}
// Tell the AppWidgetManager to perform an update on the current app widget
appWidgetManager.updateAppWidget(appWidgetId, views);*/
}
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
示例14: setRemoteAdapter
import android.widget.RemoteViews; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void setRemoteAdapter(Context context, @NonNull final RemoteViews views) {
views.setRemoteAdapter(R.id.list_view,
new Intent(context, TodayWidgetService.class));
}
示例15: onUpdate
import android.widget.RemoteViews; //導入方法依賴的package包/類
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
// There may be multiple widgets active, so update all of them
for (int appWidgetId : appWidgetIds) {
// Set up the intent that starts the BooksWidgetServe, which will
// provide the views for this collection.
Intent intent = new Intent(context, BooksWidgetService.class);
// Add the app widget ID to the intent extras.
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
// Instantiate the RemoteViews object for the app widget layout.
// using the "RemoteViews adapter".
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_bookito);
// Set up the RemoteViews object to use a RemoteViews adapter.
// This adapter connects
// to a RemoteViewsService through the specified intent.
// This is how you populate the data.
rv.setRemoteAdapter(appWidgetId, R.id.widget_list, intent);
// The empty view is displayed when the collection has no items.
// It should be in the same layout used to instantiate the RemoteViews
// object above.
rv.setEmptyView(R.id.widget_list, R.id.widget_empty_view);
// This section makes it possible for items to have individualized behavior.
// It does this by setting up a pending intent template. Individuals items of a collection
// cannot set up their own pending intents. Instead, the collection as a whole sets
// up a pending intent template, and the individual items set a fillInIntent
// to create unique behavior on an item-by-item basis.
Intent clickIntent = new Intent(context, BooksWidgetProvider.class);
// Set the action for the intent.
// When the user touches a particular view, it will have the effect of
// broadcasting TOAST_ACTION.
clickIntent.setAction(BooksWidgetProvider.CLICKED_ITEM_ACTION);
clickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
PendingIntent toastPendingIntent = PendingIntent.getBroadcast(context, 0, clickIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
rv.setPendingIntentTemplate(R.id.widget_list, toastPendingIntent);
appWidgetManager.updateAppWidget(appWidgetId, rv);
super.onUpdate(context, appWidgetManager, appWidgetIds);
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.widget_list);
}
}