Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attempt to invoke virtual method ‘android.os.Handler android.support.v4.app.FragmentHostCallback.getHandler()’ on a null object

Tags:

android

Attempt to invoke virtual method 'android.os.Handler android.support.v4.app.FragmentHostCallback.getHandler()' on a null object reference
  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1588)
  at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:330)
  at android.support.v4.app.FragmentActivity.onResume(FragmentActivity.java:441)
  at com.app.rare10.activities.ViewAllMemberActivity.onResume(ViewAllMemberActivity.java:192)
  at com.app.rare10.activities.ViewAllMemberActivity$1.onReceive(ViewAllMemberActivity.java:74)
  at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297)
  at android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46)
  at android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loop(Looper.java:135)
  at android.app.ActivityThread.main(ActivityThread.java:5254)
  at java.lang.reflect.Method.invoke(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:372)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698

I have used push notifications in my project and I'm getting this error above whenever I click on my notification. Help?

like image 807
Bhoomi Zalavadiya Avatar asked Oct 31 '22 01:10

Bhoomi Zalavadiya


1 Answers

I used a boolean to prevent whenever activity has Destroyed and has resumed.

boolean hasStop;
.
.
.
.
//here is when I need to prevent
if(!hasStop)
   //Statement
.
.
.
@Override
protected void onDestroy() {
    super.onDestroy();
    hasStop=true;
}

@Override
protected void onResume() { 
    super.onResume();
    hasStop=false;
}
like image 96
Teerapon Jeamphue Avatar answered Nov 15 '22 06:11

Teerapon Jeamphue