当前位置: 首页>>代码示例>>Java>>正文


Java RemoteViews.setOnClickPendingIntent方法代码示例

本文整理汇总了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;

}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:20,代码来源:AppWidget.java

示例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);
}
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:17,代码来源:PlayNotifyManager.java

示例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);

}
 
开发者ID:hiteshsahu,项目名称:Android-Photo-Cell-POC,代码行数:17,代码来源:FlashlightWidgetProvider.java

示例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);
    }
 
开发者ID:NICOLITE,项目名称:HutHelper,代码行数:18,代码来源:CourseWidget.java

示例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;
}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:19,代码来源:ScriptWidget.java

示例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);

    }
}
 
开发者ID:fekracomputers,项目名称:MuslimMateAndroid,代码行数:41,代码来源:CalenderWidget.java

示例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);
}
 
开发者ID:lambdasoup,项目名称:blockvote,代码行数:32,代码来源:AppWidgetUpdateService.java

示例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);
}
 
开发者ID:DysaniazzZ,项目名称:ArtOfAndroid,代码行数:16,代码来源:MyAppWidgetProvider.java

示例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);
}
 
开发者ID:StringMon,项目名称:homescreenarcade,代码行数:11,代码来源:UpDownWidget.java

示例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);
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:14,代码来源:MusicXwidget4x4.java

示例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);
}
 
开发者ID:StringMon,项目名称:homescreenarcade,代码行数:9,代码来源:FireButtonWidget.java

示例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);
    }

}
 
开发者ID:suifenge,项目名称:MusicPlayerEngine,代码行数:8,代码来源:PlayerNotification.java

示例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);

}
 
开发者ID:wuhighway,项目名称:DailyStudy,代码行数:10,代码来源:MyAppWidgetProvider.java

示例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);
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:9,代码来源:AccountWidget.java

示例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);
    }
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:29,代码来源:ServiceToggle.java


注:本文中的android.widget.RemoteViews.setOnClickPendingIntent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。