當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。