2012-05-21 46 views
16

我想通過null值執行();的AsyncTask的方法在機器人4.0它顯示錯誤 「的方法執行(整數[])是不明確的類型」,但是同樣的代碼是工作精細與Android 2.2代碼是:無法傳遞null執行(); Android 4.0中的AsyncTask的方法

public class AllianceAnalysisDemoActivity extends Activity { 
/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    new AsynPageLoader().execute(null); 
} 


public class AsynPageLoader extends AsyncTask<Integer, Integer, Bitmap> { 

    @Override 
    protected void onPreExecute() { 
     // progressBar.setVisibility(VISIBLE); 
    } 

    @Override 
    protected Bitmap doInBackground(Integer... params) { 

     return null; 
    } 

    @Override 
    protected void onPostExecute(Bitmap result) { 
     if (result != null && result.getHeight() > 0 
       && result.getWidth() > 0) { 

     }else { 

     } 
    } 

} 

}

請幫助我如何傳遞null值.execute(null);在Android 4.0的

+1

爲什麼要傳遞null?如果你不希望Integer值作爲AsyncTask的參數? –

+1

通過分配null來減少對對象的引用次數。 如果對象不再被引用,所以它將可用於垃圾收集,即編譯器將銷燬它並將空閒內存分配給其他對象。 –

+0

看到這也http://stackoverflow.com/questions/36325277/why-does-system-out-printlnnull-give-the-method-printlnchar-is-ambiguo –

回答

19

方法這應該工作:

new AsynPageLoader().execute((Integer) null); 
+1

謝謝RC。其做工精細整數但對於空數據類型Ex> 類UpdataColumnTask擴展的AsyncTask <太虛,太虛,太虛> { \t \t @覆蓋 \t \t保護無效doInBackground(虛空...... PARAMS){ \t \t \t \t \t \t return null; \t \t} \t} –

+1

有沒有其他方法可以通過指定null來減少對對象的引用次數 –

相關問題