In my Android Application the class MyApp which extends Application base class like this :
public class MyApp extends Application {
   private static MyApp instance;
   public static MyApp getInstance() {
      return instance;
   }
   @Override
   public void onCreate() {
     super.onCreate();
     instance = this;    
   }
}
declare in AndroidManifest.xml
<application android:name="com.mypackage.mypackage.MyApp">...</application>
While accessing like this from an activity class :
MyApp.getInstance()
Return null and causes Nullpointer Exception some times mostly in android version 7.0. I think this must probably due to application get killed. So how should I reinitiated the application class so that it getInstance() return non-null value.
 
     
     
    