I want to send some message from asytask to me main activity. I want to do this with message object (handler). in my main activity I created this
final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
msg.toString();
}
};
the object that I pass to asytask
new splash(first.this,mHandler).execute();
and the asytask that send message to activity from this method
protected void onPostExecute(String result) {
Message msg = new Message();
Bundle bundle = new Bundle();
bundle.putString("ActivityName",this.newActivity);
msg.setData(bundle);
mHandler.sendMessage(msg);
Dialog.dismiss();
the logcat
09-29 11:55:41.631: E/AndroidRuntime(473): FATAL EXCEPTION: main
09-29 11:55:41.631: E/AndroidRuntime(473): java.lang.NullPointerException
09-29 11:55:41.631: E/AndroidRuntime(473): at tools.splash.onPostExecute(splash.java:109)
09-29 11:55:41.631: E/AndroidRuntime(473): at tools.splash.onPostExecute(splash.java:1)
09-29 11:55:41.631: E/AndroidRuntime(473): at android.os.AsyncTask.finish(AsyncTask.java:417)
09-29 11:55:41.631: E/AndroidRuntime(473): at android.os.AsyncTask.access$300(AsyncTask.java:127)
09-29 11:55:41.631: E/AndroidRuntime(473): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
09-29 11:55:41.631: E/AndroidRuntime(473): at android.os.Handler.dispatchMessage(Handler.java:99)
09-29 11:55:41.631: E/AndroidRuntime(473): at android.os.Looper.loop(Looper.java:123)
09-29 11:55:41.631: E/AndroidRuntime(473): at android.app.ActivityThread.main(ActivityThread.java:3683)
09-29 11:55:41.631: E/AndroidRuntime(473): at java.lang.reflect.Method.invokeNative(Native Method)
09-29 11:55:41.631: E/AndroidRuntime(473): at java.lang.reflect.Method.invoke(Method.java:507)
09-29 11:55:41.631: E/AndroidRuntime(473): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-29 11:55:41.631: E/AndroidRuntime(473): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-29 11:55:41.631: E/AndroidRuntime(473): at dalvik.system.NativeStart.main(Native Method)