내 Android 시간 위젯이 자체적으로 업데이트되지 않는 이유는 무엇입니까? 홈 화면에 대해 & 시간 위젯을 만들었지 만 문제는 화면 방향이 가로 방향에서 세로 방향으로 변경된 경우에만 내 시간 위젯이 업데이트된다는 것입니다. 실시간 모드에서 자동 업데이트되어야합니다. 여기에 내 코드가 있습니다 :Android 시간 위젯이 업데이트되지 않는 이유가 무엇인가요?
public class PointlessWidget extends AppWidgetProvider {
Time mCalendar;
float mMinutes;
float mHour;
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
// TODO Auto-generated method stub
super.onUpdate(context, appWidgetManager, appWidgetIds);
mCalendar = new Time();
// Line below sets time that will be displayed - modify if needed.
mCalendar.setToNow();
int hour = mCalendar.hour;
int minute = mCalendar.minute;
int second = mCalendar.second;
mMinutes = minute + second/60.0f;
mHour = hour + minute/60.0f;
final int N = appWidgetIds.length;
for (int i = 0; i < N; i++) {
int awID = appWidgetIds[i];
RemoteViews v = new RemoteViews(context.getPackageName(),
R.layout.widget);
v.setTextViewText(R.id.textHour, " " + hour);
v.setTextViewText(R.id.textMinute, " " + minute);
appWidgetManager.updateAppWidget(awID, v);
}
}
@Override
public void onDeleted(Context context, int[] appWidgetIds) {
// TODO Auto-generated method stub
super.onDeleted(context, appWidgetIds);
Toast.makeText(context, "Widget Deleted!", Toast.LENGTH_SHORT).show();
}
}
그리고 여기 내 매니페스트입니다 :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.androidwidgets"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver android:name=".PointlessWidget" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_stuff" />
</receiver>
<service android:name="TimeSettableAnalogClockService"/>
<activity android:name=".WidgetsConfig" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
</application>
</manifest>
그리고 이것은 내 widget_stuff XML이다. updatePeriodMillis = "1000"또는 이와 동등한 변환을 이미 1 초로 설정했습니다.
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialLayout="@layout/widget"
android:minHeight="30dp"
android:minWidth="274dp"
android:updatePeriodMillis="1000" >
</appwidget-provider>
확인이 솔루션을 http://stackoverflow.com/questions/2078122/android-widget-not-updating 30 분을 기다려야한다고 생각합니다. –