我正在从 main_activity 打这个电话
Intent createAccount = new Intent(mainact_Context,Register_activity.class);
startActivity(createAccount);
这是调用的活动AsyncTask
:
public class Register_activity extends Activity {
Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
context = this;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register_activity);
Button RegButton = (Button) this.findViewById(R.id.Regbutton);
RegButton.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
RegisterWithServer regser = new RegisterWithServer(context);
regser.execute();
}
});
setupActionBar();
}
}
在我的异步活动中,我有这个:
public class RegisterWithServer extends AsyncTask <String,Void,String> {
Context con;
public RegisterWithServer(Context context)
{
con = context;
}
protected String doInBackground(String... params) {
//this code gets executed perfectly
}
@Override
protected void onPostExecute(String result)
{
/*I tried doing something with the context and the result string here and it worked too.*/
Toast.makeText(con, result , Toast.LENGTH_SHORT).show();
}
}
该doInBackground()
部分得到完美执行。该onPostExecute()
部分被调用但未Toast
显示。任何人都可以发现任何东西吗?