Code i have use
public class DemoAsynTask extends AsyncTask{
@Override
protected void onPreExecute(){
try{
MainActivity myActivity = new MainActivity();
myActivity.super.onCreate(savedInstanceState);
myActivity.setContentView(R.layout.activity_main);
EditText txtInformation = (EditText) myActivity.findViewById(R.id.txtInformation);
txtInformation.setText("TESTING");
}catch(Exception ex){
ex.printStackTrace();
}
}
@Override
protected Object doInBackground(Object... params) {
// TODO Auto-generated method stub
return null;
}
}
The DemoAsynTask class is not inside, i have seen an example is work but class inside MainActivity
public class MainActivity extends activity{
public class DemoAsynTask extends AsyncTask{
}
}
The DemoAsynTask class is seperate files and i want call it seperately but it have null pointer exception.
public class MainActivity extends activity{
}
public class DemoAsynTask extends AsyncTask{
}
Error Log java.lang.NullPointerException