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
need instantiate
handler
, i.e., likehandler h = new handler(); h.sendemptymessage(0);
or
add
static
modifiersendemptymessage
method:public static void sendemptymessage(int i) { ... ^^^^^^
Comments
Post a Comment