Try adb logcat in the command prompt while running the application....There u can see which all exceptions are coming and where it is crashing....
Regards, SREEHARI On Mar 3, 9:34 am, themindiswasted <abarban...@gmail.com> wrote: > Can someone look at this code and see why it is locking up the Android > OS. I am receiving force close messages on a.core after about a > minute. > > Thank you so much in advance: > > import java.text.DateFormat; > import java.text.SimpleDateFormat; > import java.util.Calendar; > import java.util.Date; > import java.util.GregorianCalendar; > import java.util.Locale; > import java.util.Timer; > import java.util.TimerTask; > > import android.appwidget.AppWidgetManager; > import android.appwidget.AppWidgetProvider; > import android.content.ComponentName; > import android.content.Context; > import android.content.Intent; > import android.widget.RemoteViews; > > public class HelloWidget extends AppWidgetProvider { > Calendar cal = new GregorianCalendar(); > int month = cal.get(Calendar.MONTH); > int year = cal.get(Calendar.YEAR); > int day = cal.get(Calendar.DAY_OF_MONTH); > > //@Override > public void onUpdate(Context context, AppWidgetManager > appWidgetManager,int[] appWidgetIds) { > Timer timer = new Timer(); > timer.scheduleAtFixedRate(new MyTime(context, > appWidgetManager), 1, > 1000); > } > > private class MyTime extends TimerTask { > RemoteViews remoteViews; > AppWidgetManager appWidgetManager; > ComponentName thisWidget; > DateFormat format = > new SimpleDateFormat("HH:mm:ss",Locale.getDefault()); > //DateFormat format = > SimpleDateFormat.getTimeInstance(SimpleDateFormat.MEDIUM, > //Locale.getDefault()); > > public MyTime(Context context, AppWidgetManager appWidgetManager) > { > this.appWidgetManager = appWidgetManager; > remoteViews = new > RemoteViews(context.getPackageName(), > R.layout.main); > thisWidget = new ComponentName(context, > HelloWidget.class); > remoteViews.setTextViewText(R.id.widget_dateView, > day + "." + (month + 1) + "." + year); > } > > @Override > public void run() { > remoteViews.setTextViewText(R.id.widget_textview, > format.format(new Date())); > > appWidgetManager.updateAppWidget(thisWidget, remoteViews); > } > } > > //@Override > public void onReceive(Context context, Intent intent) { > // v1.5 fix that doesn't call onDelete Action > final String action = intent.getAction(); > if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)) > { > final int appWidgetId = intent.getExtras().getInt( > AppWidgetManager.EXTRA_APPWIDGET_ID, > > AppWidgetManager.INVALID_APPWIDGET_ID); > if (appWidgetId != > AppWidgetManager.INVALID_APPWIDGET_ID) { > this.onDeleted(context, new int[] { > appWidgetId }); > } > } else { > super.onReceive(context, intent); > } > } > > } > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en