Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CarManagementWidget extends AppWidgetProvider {
- public static final String TAG = "CarManagementWidget";
- public static final String ACTION_COMMAND_LOCK = "action_command_lock";
- public static final String ACTION_COMMAND_UNLOCK = "action_command_unlock";
- private PendingIntent mServicePendingIntent;
- static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
- RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
- Intent intentActionLock = new Intent(context, CarManagementWidget.class);
- intentActionLock.putExtra("command", "close");
- intentActionLock.setAction(ACTION_COMMAND_LOCK);
- Intent intentActionUnlock = new Intent(context, CarManagementWidget.class);
- intentActionUnlock.putExtra("command", "open");
- intentActionUnlock.setAction(ACTION_COMMAND_UNLOCK);
- PendingIntent pendingIntentLock = PendingIntent.getService(context, 0, intentActionLock, PendingIntent.FLAG_UPDATE_CURRENT);
- remoteViews.setOnClickPendingIntent(R.id.lockImageButton, pendingIntentLock);
- PendingIntent pendingIntentUnlock = PendingIntent.getService(context, 0, intentActionUnlock, PendingIntent.FLAG_UPDATE_CURRENT);
- remoteViews.setOnClickPendingIntent(R.id.unlockImageButton, pendingIntentUnlock);
- //PendingIntent pendingIntentLock = PendingIntent.getBroadcast(context, 0, intentActionLock, PendingIntent.FLAG_UPDATE_CURRENT);
- //remoteViews.setOnClickPendingIntent(R.id.lockImageButton, pendingIntentLock);
- //PendingIntent pendingIntentUnlock = PendingIntent.getBroadcast(context, 0, intentActionUnlock, PendingIntent.FLAG_UPDATE_CURRENT);
- //remoteViews.setOnClickPendingIntent(R.id.unlockImageButton, pendingIntentUnlock);
- appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
- }
- @Override
- public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
- for (int appWidgetId : appWidgetIds) {
- updateAppWidget(context, appWidgetManager, appWidgetId);
- }
- }
- @Override
- public void onReceive(Context context, Intent intent) {
- super.onReceive(context, intent);
- }
- }
Add Comment
Please, Sign In to add comment