1

I am newbie android programmer and I found out handle issue with this program, when i try to run the below program it is forcefully closed.

Why is this happening ?? How to solve this problem ?? Thank you

public class Antivirus extends Activity {

    protected static final int STOP = 100;
    private ImageView iv;
    private ProgressBar pb;
    private LinearLayout ll;
    private AnimationDrawable anim;
    private ScrollView sv;
    private SQLiteDatabase db;
    private boolean flagscanning = false;
    private Handler handler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
             if(msg.what==STOP){
                 ll.removeAllViews();
                 anim.stop();

                 }
             String str = (String) msg.obj;
             TextView tv = new TextView(getApplicationContext());
             tv.setText(str);
             ll.setOrientation(LinearLayout.VERTICAL);
             ll.addView(tv);
             sv.scrollBy(0, 20);

            System.out.println(str);

        }

    };
NREZ
  • 942
  • 9
  • 13
  • Read [this](http://stackoverflow.com/a/11408340/430480) for more information. There are many posts on SO which give insights into this, you could have tried searching first. – Rajeev Jul 22 '13 at 07:45
  • share your logcat - detailed logcat...that will be helpful – cafebabe1991 Jul 22 '13 at 07:45
  • possible duplicate of [This Handler class should be static or leaks might occur: IncomingHandler](http://stackoverflow.com/questions/11407943/this-handler-class-should-be-static-or-leaks-might-occur-incominghandler) – Rajeev Jul 22 '13 at 07:45
  • http://www.androiddesignpatterns.com/2013/01/inner-class-handler-memory-leak.html. check this link. – Raghunandan Jul 22 '13 at 08:10

0 Answers0