Digital clock does not change time

I am developing one digital clock widget. I wrote the code. But this is not an update of time. I do not use any service and do not work in the simulator. My code is as follows:

public class ExampleAppWidgetProvider extends AppWidgetProvider { DateFormat df = new SimpleDateFormat("hh:mm:ss"); @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager,int[] appWidgetIds) { final int NUM = appWidgetIds.length; for(int i =0; i<NUM; i++) { int appWidgetId = appWidgetIds[i]; RemoteViews remoteview = new RemoteViews(context.getPackageName(), R.layout.widget1); // remoteview.setOnClickPendingIntent(R.id.button, pending); remoteview.setTextViewText(R.id.Time_text, df.format(new Date())); appWidgetManager.updateAppWidget(appWidgetId, remoteview); } } 

My widget_layout.xml is below:

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center" android:layout_margin="4dp" android:background="@drawable/widgetstyle" > <TextView android:id="@+id/Time_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textStyle="bold" /> </LinearLayout> 

Can anyone help?

+1
source share

Source: https://habr.com/ru/post/1380700/


All Articles