1

当我打开我的应用程序并且这是在后台时,我收到了 Nullpointer 异常。我的 onResume 调用了一个调用此方法的 Asyntask:

public boolean reloadIni() throws NetworkConnetionException {
   if(mMyApp == null)//chek if the object has been deleted by the gc.
   {
     Log.d(TAG,"task mMyApp is null, initialize mMyApp");
     mMyApp = (MyApp) getApplicationContext();          
   }
   User userLogin = mMyApp.getUserLogin();  
  //....more stuff
}   

但正如你所看到的,我正在检查我的变量 mMyApp 是否为!= null。getApplicationContext() 是否有可能返回 null?

4

0 回答 0