Code example for RemoteViews

	public static int THEME_NARROW_LIGHT = R.layout.my_number_widget_narrow_light;
	public static int THEME_NARROW_DARK = R.layout.my_number_widget_narrow_dark;
	public static void updateWidget(Context context, String phoneNumber, int theme) {
		// Redraw the widget now 
		RemoteViews views = new RemoteViews(context.getPackageName(), theme);
		if (theme == THEME_NARROW_LIGHT || theme == THEME_NARROW_DARK) {
			doNarrowWidgetUpdate(context, phoneNumber, views);
		else { 
			doWideWidgetUpdate(context, phoneNumber, views);
	private static void doNarrowWidgetUpdate(Context context, String phoneNumber, RemoteViews views) {
		// Attach a click listener to display the phone number 
		Intent action = new Intent(context.getApplicationContext(), DisplayPhoneNumber.class);
		action.putExtra("PHONE_NUMBER", phoneNumber);
		PendingIntent pendingIntent = PendingIntent.getActivity(context.getApplicationContext(), 0, action, PendingIntent.FLAG_CANCEL_CURRENT);
Contextual code suggestions in your IDE  Get Codota for Java