I know that this is not a serious question (and my code is not perfect...), but I wonder why after initialization of the field, which passed as a parameter to the method, the field has a null pointer (null)?
public class MainActivity extends ActionBarActivity{
private ProgressDialog prdialog;
ProgressDialog prepareDialog(ProgressDialog pr){
if (pr==null){
pr=new ProgressDialog(this);
}
pr.setTitle(R.string.Download);
pr.setCanceledOnTouchOutside(false);
pr.setCancelable(false);
pr.setMessage(getString(R.string.Wait_));
return pr;
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
prepareDialog(prdialog).show();
//do some operations
prdialog.dismiss();//here my app is crashes because prdialog=null
}
}