Handler can is defined in the Activity top level
public class MyActivity extends Activity{
...
private Handler handler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message msg) {
Log.i(P.TAG, "Handler got message");
if (msg.what == GOT_RECIEVER_HOST) {
Log.i(P.Tag, "GOT_RECIEVER_HOST");
Toast.makeText(ctxStatic, "Motion Detected", Toast.LENGTH_LONG).show();}
}
};
...
}
From a Thread, or AsyncTask in the Activity
handler.sendEmptyMessage(GOT_RECIEVER_HOST);
No comments:
Post a Comment