本文整理汇总了Java中android.widget.RemoteViews.setOnClickPendingIntent方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteViews.setOnClickPendingIntent方法的具体用法?Java RemoteViews.setOnClickPendingIntent怎么用?Java RemoteViews.setOnClickPendingIntent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.RemoteViews
的用法示例。
在下文中一共展示了RemoteViews.setOnClickPendingIntent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildUpdate
import android.widget.RemoteViews; //导入方法依赖的package包/类
private RemoteViews buildUpdate(Context context) {
RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.widget);
AudioManager audioManager = (AudioManager) context.getSystemService(Activity.AUDIO_SERVICE);
if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) {
updateViews.setImageViewResource(R.id.phoneState, R.drawable.phone_state_normal);
audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
} else {
updateViews.setImageViewResource(R.id.phoneState, R.drawable.phone_state_silent);
audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
}
Intent i = new Intent(this, AppWidget.class);
PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0);
updateViews.setOnClickPendingIntent(R.id.phoneState, pi);
return updateViews;
}
示例2: setCommonClickPending
import android.widget.RemoteViews; //导入方法依赖的package包/类
private void setCommonClickPending(RemoteViews view) {
Intent playOrPause = new Intent(PLAY_NOTIFY);
playOrPause.putExtra(PLAY_NOTIFY_CODE, PLAY_STATUS_SWITCH);
PendingIntent p1 = PendingIntent.getBroadcast(activity, PLAY_STATUS_SWITCH, playOrPause, PendingIntent.FLAG_UPDATE_CURRENT);
view.setOnClickPendingIntent(R.id.play_notify_play, p1);
Intent next = new Intent(PLAY_NOTIFY);
next.putExtra(PLAY_NOTIFY_CODE, PLAY_NEXT);
PendingIntent p2 = PendingIntent.getBroadcast(activity, PLAY_NEXT, next, PendingIntent.FLAG_UPDATE_CURRENT);
view.setOnClickPendingIntent(R.id.play_notify_next, p2);
Intent close = new Intent(PLAY_NOTIFY);
close.putExtra(PLAY_NOTIFY_CODE, PLAY_NOTIFY_CLOSE);
PendingIntent p3 = PendingIntent.getBroadcast(activity, PLAY_NOTIFY_CLOSE, close, PendingIntent.FLAG_UPDATE_CURRENT);
view.setOnClickPendingIntent(R.id.play_notify_close, p3);
}
示例3: onUpdate
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
Intent receiver = new Intent(context, FlashlightWidgetReceiver.class);
receiver.setAction("COM_FLASHLIGHT");
receiver.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, receiver, 0);
RemoteViews views = new RemoteViews(context.getPackageName(),
R.layout.flash_light_widget);
views.setOnClickPendingIntent(R.id.button, pendingIntent);
appWidgetManager.updateAppWidget(appWidgetIds, views);
}
示例4: onWidgetUpdate
import android.widget.RemoteViews; //导入方法依赖的package包/类
private void onWidgetUpdate(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.course_widget);
remoteViews.setTextViewText(R.id.tv_widget_weeknum, "第" + DateUtils.getNowWeek() + "周");
Intent intent = new Intent(context, CourseWidget.class);
intent.setAction(WEEK_PRE_ACTION);
PendingIntent pendingIntentpre = PendingIntent.getBroadcast(context, 0, intent, 0);
Intent intent1 = new Intent(context, CourseWidget.class);
intent1.setAction(WEEK_NEXT_ACTION);
PendingIntent pendingIntentnnext = PendingIntent.getBroadcast(context, 0, intent1, 0);
remoteViews.setOnClickPendingIntent(R.id.btn_widget_previous, pendingIntentpre);
remoteViews.setOnClickPendingIntent(R.id.btn_widget_next, pendingIntentnnext);
init(context, remoteViews);
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
示例5: updateWidget
import android.widget.RemoteViews; //导入方法依赖的package包/类
static boolean updateWidget(Context context, int widgetId, String path) {
if (TextUtils.isEmpty(path) || widgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
return false;
}
String name = PFiles.getNameWithoutExtension(path);
int requestCode = ScriptWidgets.getRequestCodeForAppWidgetId(widgetId);
Log.d(LOG_TAG, "updateWidget: id = " + widgetId + ", requestCode = " + requestCode + ", path = " + path);
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_script_shortcut);
views.setOnClickPendingIntent(R.id.widget, PendingIntent.getActivity(context, requestCode,
new Intent(context, RunIntentActivity.class)
.putExtra(ScriptIntents.EXTRA_KEY_PATH, path)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), PendingIntent.FLAG_UPDATE_CURRENT));
views.setTextViewText(R.id.name, name);
appWidgetManager.updateAppWidget(widgetId, views);
ScriptWidgets.setPathForAppWidgetId(widgetId, path);
return true;
}
示例6: onUpdate
import android.widget.RemoteViews; //导入方法依赖的package包/类
/**
* Function fire on system update widget
*
* @param context Context of application
* @param appWidgetManager App widget manger
* @param appWidgetIds Widget system ids
*/
@Override
public void onUpdate(Context context, final AppWidgetManager appWidgetManager, int[] appWidgetIds) {
final int count = appWidgetIds.length;
//set widget language with the system language
Locale locale = new Locale(Resources.getSystem().getConfiguration().locale.getLanguage());
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
this.context = context;
//loop in all widgets
for (int i = 0; i < count; i++) {
svcIntent = new Intent(context, CalenderRemoteViewsService.class);
final int widgetId = appWidgetIds[i];
remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_calender);
remoteViews.setRemoteAdapter(R.id.calendar_pager, svcIntent);
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds[i], R.id.calendar_pager);
HGDate hgDate = new HGDate();
hgDate.toHigri();
remoteViews.setTextViewText(R.id.textView8, Dates.getCurrentWeekDay());
remoteViews.setTextViewText(R.id.textView7, NumbersLocal.convertToNumberTypeSystem(context, hgDate.getDay() + ""));
remoteViews.setTextViewText(R.id.textView24, NumbersLocal.convertToNumberTypeSystem(context, hgDate.getYear() + ""));
remoteViews.setTextViewText(R.id.curr_month_txt, Dates.islamicMonthName(context, hgDate.getMonth() - 1));
remoteViews.setTextViewText(R.id.curr_month_txt_other, showOtherMonth(hgDate));
PendingIntent configPendingIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0);
remoteViews.setOnClickPendingIntent(R.id.relativeLayout, configPendingIntent);
appWidgetManager.updateAppWidget(widgetId, remoteViews);
}
}
示例7: onHandleWork
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
protected void onHandleWork(@NonNull Intent intent) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
int[] ids = appWidgetManager.getAppWidgetIds(new ComponentName(this, AppWidget.class));
RemoteViews views = new RemoteViews(getPackageName(), R.layout.app_widget);
try (Cursor cursor = getContentResolver().query(StatsProvider.CONTENT_URI, null, null, null, null)) {
if (cursor == null || cursor.getCount() <= 0) {
return;
}
cursor.moveToPrevious();
while (cursor.moveToNext()) {
switch (getEnum(cursor, Stats.ID, Id.class)) {
case S2X:
setCell(views, R.id.appwidget_value_sw, getFloat(cursor, Stats.D1));
break;
case EC:
setCell(views, R.id.appwidget_value_ec, getFloat(cursor, Stats.D1));
break;
}
}
}
Intent mainIntent = new Intent(this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, mainIntent, 0);
views.setOnClickPendingIntent(R.id.appwidget_root, pendingIntent);
appWidgetManager.updateAppWidget(ids, views);
}
示例8: onWidgetUpdate
import android.widget.RemoteViews; //导入方法依赖的package包/类
/**
* 更新桌面小部件
*/
private void onWidgetUpdate(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
Log.d(TAG, "appWidgetId = " + appWidgetId);
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.layout_widget);
//设置点击事件
Intent clickIntent = new Intent(ACTION_CLICK);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, clickIntent, 0);
remoteViews.setOnClickPendingIntent(R.id.iv_widget, pendingIntent);
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
示例9: updateAppWidget
import android.widget.RemoteViews; //导入方法依赖的package包/类
protected void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
int appWidgetId) {
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.up_down_widget);
views.setOnClickPendingIntent(R.id.up_btn,
PendingIntent.getBroadcast(context, 0, new Intent(ArcadeCommon.ACTION_UP), 0));
views.setOnClickPendingIntent(R.id.down_btn,
PendingIntent.getBroadcast(context, 0, new Intent(ArcadeCommon.ACTION_DOWN), 0));
appWidgetManager.updateAppWidget(appWidgetId, views);
}
示例10: controls
import android.widget.RemoteViews; //导入方法依赖的package包/类
private void controls(RemoteViews remoteViews, Context context) {
PendingIntent clickedview = PendingIntent.getService(context, 0, new Intent(context, MusicXService.class).setAction(ACTION_PLAYINGVIEW), 0);
PendingIntent nextIntent = PendingIntent.getService(context, 0, new Intent(context, MusicXService.class).setAction(ACTION_NEXT), 0);
PendingIntent previousIntent = PendingIntent.getService(context, 0, new Intent(context, MusicXService.class).setAction(ACTION_PREVIOUS), 0);
PendingIntent toggleIntent = PendingIntent.getService(context, 0, new Intent(context, MusicXService.class).setAction(ACTION_TOGGLE), 0);
PendingIntent savefavIntent = PendingIntent.getService(context, 0, new Intent(context, MusicXService.class).setAction(ACTION_FAV), 0);
remoteViews.setOnClickPendingIntent(R.id.artwork, clickedview);
remoteViews.setOnClickPendingIntent(R.id.toggle, toggleIntent);
remoteViews.setOnClickPendingIntent(R.id.next, nextIntent);
remoteViews.setOnClickPendingIntent(R.id.prev, previousIntent);
remoteViews.setOnClickPendingIntent(R.id.action_favorite, savefavIntent);
}
示例11: updateAppWidget
import android.widget.RemoteViews; //导入方法依赖的package包/类
protected void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
int appWidgetId) {
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.fire_button_widget);
views.setOnClickPendingIntent(R.id.fire_btn,
PendingIntent.getBroadcast(context, 0, new Intent(ArcadeCommon.ACTION_FIRE), 0));
appWidgetManager.updateAppWidget(appWidgetId, views);
}
示例12: initPendingIntents
import android.widget.RemoteViews; //导入方法依赖的package包/类
private void initPendingIntents(RemoteViews views) {
for(int i = 0; i < resIds.length; ++i) {
PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, requestCodes[i], new Intent(actions[i]), FLAG);
views.setOnClickPendingIntent(this.resIds[i], pendingIntent);
}
}
示例13: onWidgetUpdate
import android.widget.RemoteViews; //导入方法依赖的package包/类
private void onWidgetUpdate(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
Intent intent = new Intent();
intent.setAction(CLICK_ACTION);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
remoteViews.setOnClickPendingIntent(R.id.imageview, pendingIntent);
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
示例14: addButtonsClick
import android.widget.RemoteViews; //导入方法依赖的package包/类
private static void addButtonsClick(Context context, RemoteViews updateViews) {
Intent intent = new Intent(context, TransactionActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
updateViews.setOnClickPendingIntent(R.id.add_transaction, pendingIntent);
intent = new Intent(context, TransferActivity.class);
pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
updateViews.setOnClickPendingIntent(R.id.add_transfer, pendingIntent);
}
示例15: onUpdate
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
// Perform this loop procedure for each App Widget that belongs to this provider
for (int appWidgetId : appWidgetIds) {
// Get the layout for the App Widget and attach an on-click listener
// to the button
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.service_toggle_widget);
if (NLService.isEnabled()) {
views.setImageViewResource(R.id.widgetToggleButton,R.drawable.ic_speaker_notes_white_48dp);
views.setInt(R.id.widgetToggleButton, "setBackgroundResource", R.drawable.round_rectangle_green);
views.setTextViewText(R.id.widgetToggleText, context.getString(R.string.widget_on_text));
views.setTextColor(R.id.widgetToggleText, ContextCompat.getColor(context, R.color.green));
} else {
views.setImageViewResource(R.id.widgetToggleButton,R.drawable.ic_speaker_notes_off_white_48dp);
views.setInt(R.id.widgetToggleButton, "setBackgroundResource", R.drawable.round_rectangle_red);
views.setTextViewText(R.id.widgetToggleText, context.getString(R.string.widget_off_text));
views.setTextColor(R.id.widgetToggleText, ContextCompat.getColor(context, R.color.red));
}
views.setOnClickPendingIntent(
R.id.widgetToggleButton,
getPendingSelfIntent(context, appWidgetId, TOGGLE_CLICKED));
// Tell the AppWidgetManager to perform an update on the current app widget
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}