java - Cannot make a static reference to the non-static method sendEmptyMessage(int) from the type Handler -


i have error "cannot make static reference non-static method sendemptymessage(int) type handler"

how fix it? think problem class not activity?

        new thread() {             public void run() {             try {                      list<sail> sails = searchsails();                      selectsailintent.putparcelablearraylistextra(                             constant.sails, new arraylist<sail>(sails));                      getcontext().startactivity(selectsailintent);                      handler.sendemptymessage(0);                  } catch (exception e) {                      alertdialog.setmessage(e.getmessage());                      handler.sendemptymessage(1);                  }             }         }.start();     } }; 

"cannot make static reference non-static method sendemptymessage(int) type handler"

this due fact handler refers class, sendemptymessage not static method (should called on object, , not on class).

how fix it?

to able call sendemptymessage method either

  1. need instantiate handler, i.e., like

    handler h = new handler(); h.sendemptymessage(0); 

    or

  2. add static modifier sendemptymessage method:

    public static void sendemptymessage(int i) { ...        ^^^^^^ 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -