//MainWidget.java
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
Log.w("in-service", "onUpdate method called");
ComponentName thisWidget = new ComponentName(context, MainWidget.class);
int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);
// Build the intent to call the service
Intent intent = new Intent(context.getApplicationContext(), UpdateWidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, allWidgetIds);
// Update the widgets via the service
context.startService(intent);
}
//UpdateWidgetService.java
@Override
public void onStart(Intent intent, int startId) {
Log.w("int-service", "line 1");
Context context = this.getApplicationContext();
Log.w("int-service", "line 2");
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
int[] allWidgetIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
for (int widgetId : allWidgetIds) {
Log.w("int-service", "service");
// create some random data
Intent active = new Intent(this.getApplicationContext(), MainWidget.class);
}
stopSelf();
Log.w("int-service", "server on start command");
super.onStartCommand(intent, 0, startId);
}
자꾸 에러가 나서 제가 썼던 쏘스 다 지우고 기본적인걸로만 일단 해보고 돌려봤는데 역시 같은 에러네요
어떤 부분이 잘 못되서 그러는건지..
일단 onCreate에 있는 소스를 반본해서 계속 불러냅니다.. 그러다가 stackoverflowerror를 던저 버리는데요
08-22 10:58:14.978: E/AndroidRuntime(31757): FATAL EXCEPTION: main
08-22 10:58:14.978: E/AndroidRuntime(31757): Process: com.rj.buttonwidgets, PID: 31757
08-22 10:58:14.978: E/AndroidRuntime(31757): java.lang.StackOverflowError
.
.
.
가 끝납니다..
제가 service를 MainWidget.java에서 잘 못 불러내는 건가요??
아니면 제가 UpdateWidgetService.java에서 뭘 잘못 구현 한건가요??