2013-09-21 63 views
0

我有一个数据搜索我的android应用程序和调试通过控制台,当我检查控制台时,我看到doInBackground工作正常,但它没有调用onPostExecute后。我不知道是因为什么,有人可以帮忙吗?OnPostExecute不会调用doInBackground后成功

protected List<Recipe> doInBackground(Void... params) { 
     try { 
      List<Recipe> recipes=RecipeService.getRecipes(context,"a"); 
      if(recipes != null) android.util.Log.i(TAG,"encontrados"); 
      return recipes; 
     } catch (java.io.IOException e) { 
      android.util.Log.e(TAG,e.getMessage(),e); 
      android.util.Log.i(TAG,"ta akiiiiii"); 
      com.android.utils.AndroidUtils.AlertDialog(context,R.string.name_io); 
     }finally{ 
      progresso.dismiss(); 
     } 
     return null; 
    } 


//Update a view 


protected void OnPostExecute(List<Recipe> recipes) { 
    android.util.Log.i(TAG,"are here"); 
    for (Recipe recipe : recipes) { 
     android.util.Log.i(TAG,"Carro: "+recipe.name); 
    } 
} 

日志在这里永远不会执行,请有一些错误? trydoInBackground的作品。

回答

1

onPostExecute()而不是OnPostExecute()。在onPostExecute()中使用小写字母o

这种替换代码:

@Override 
protected void onPostExecute(List<Recipe> recipes) { 
    android.util.Log.i(TAG,"are here"); 
    for (Recipe recipe : recipes) { 
     android.util.Log.i(TAG,"Carro: "+recipe.name); 
    } 
} 

总是尝试添加@Override注释,如果你想覆盖的方法。这样你就可以知道你是否正确地写了方法签名。

1

你的方法是大写,打破了Java约定。实际的方法称为onPostExecute()。由于名称不同,因此实际上并未覆盖该方法。这种事情就是为什么@Override注释非常有用 - 如果你使用它,它会给你一个编译错误。

相关问题