2
Android (C#) 용 Mono를 사용하여 간단한 홈 화면 위젯을 만드는 데 필요한 자습서가 있습니까? 공식 사이트에는 자습서가없는 위젯 코드 만 있습니다. 위젯에 텍스트를 작성하고 매 x마다 텍스트를 업데이트하면됩니다.Android 용 Android 위젯 자습서
Android (C#) 용 Mono를 사용하여 간단한 홈 화면 위젯을 만드는 데 필요한 자습서가 있습니까? 공식 사이트에는 자습서가없는 위젯 코드 만 있습니다. 위젯에 텍스트를 작성하고 매 x마다 텍스트를 업데이트하면됩니다.Android 용 Android 위젯 자습서
updatePeriodMillis 속성 값을 설정하면 onUpdate 메소드가 해당 기간과 정확히 일치하는지 보장 할 수 없으므로 AlarmManager를 처리해야합니다. https://github.com/xamarin/monodroid-samples/tree/master/SimpleWidget에서
, 이런 식의 onUpdate 대체 :
private PendingIntent service = null;
public override void OnUpdate (Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
{
//// To prevent any ANR timeouts, we perform the update in a service
//context.StartService (new Intent (context, typeof (UpdateService)));
AlarmManager m = (AlarmManager) context.GetSystemService(Context.AlarmService);
Intent i = new Intent (context, typeof (UpdateService));
if (service == null)
{
service = PendingIntent.GetService(context, 0, i, PendingIntentFlags.CancelCurrent);
}
m.SetRepeating(AlarmType.Rtc, 0, 1000 * 3, service);
}
을 그런 다음 서비스 :
WordEntry entry = new WordEntry() { Title = "test", Description = DateTime.Now.ToLongTimeString() };
위젯 시간을 3 초마다 새로 고쳐집니다.
희망이 도움이됩니다.