위젯이있는 앱이 있습니다. 위젯으로 앱을 시작하고 싶지만 부팅 후 내 위젯이 클릭에 응답하지 않습니다. 앱을 정상적으로 시작한 후에 만 (다시 닫으면) 위젯이 위젯 자체의 클릭에 응답하기 시작합니다.부팅 후 내 Android 2.3 위젯이 클릭에 응답하지 않는 이유는 무엇입니까?
이것은 어떻게 설정의 AppWidgetProvider와 위젯 :
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
{ final int ids = appWidgetIds.length;
for(int i=0;i<ids;i++)
{ int appWidgetId = appWidgetIds[i];
Intent intent = new Intent(context, TestReceiver.class);
intent.setAction(ACTION_WIDGET_RECEIVER);
intent.setClassName(TestReceiver.class.getPackage().getName(), TestReceiver.class.getName());
PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0);
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
views.setOnClickPendingIntent(R.id.widget_root, pi);
views.setTextViewText(R.id.widgetclock, "Loading...");
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}
내가 한 번 이상 먼저 시작하지 않고도 내 응용 프로그램은 부팅 후 위젯에 클릭을 등록되도록 변경해야합니까?
왜 * 및 * a 클래스를 사용하고 있습니까? 일반적으로 둘 중 하나를 사용합니다. – CommonsWare
그렇지 않으면 작동하지 않기 때문입니다. – HardCoder
"그렇지 않으면 작동하지 않기 때문에"- 다른 모든 사람들에게 유용합니다. 어쩌면'BroadcastReceivers'와'Intent' 시스템이 어떻게 작동하는지 배우는 시간을 갖고 나서 앱 위젯을 쓰려고 노력해야 할 것입니다. – CommonsWare