I managed to successfully process an HttpPost of a JSON Object through AsyncTask. As you all know whole the coding goes in the doInBackground() method and afterwards onPostExecute() whatever is needed to show as UI goes there. Therefore, I want to show a dialog box with an OK button that the procedure has been successfully finished.
But I get that notorious “Source Not Found” run-time error while I debug/run.
Here’s the link of the scrshot of the error I took :
Dialog.class missing!
And the code is like this:
protected void onPostExecute(JSONObject result)
{
if (statusCode==HttpStatus.SC_CREATED)
{
AlertDialog.Builder msgBox = new AlertDialog.Builder(getBaseContext());
msgBox.setTitle("User registration");
msgBox.setIcon(R.drawable.confirmed_icon);
msgBox.setMessage("Registration succesfully completed!");
msgBox.setPositiveButton("OK", new OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
dialog.dismiss();
/*Intent intent = new Intent(getApplicationContext(), ScardsMainActivity.class);
startActivity(intent);*/
}
});
msgBox.create();
msgBox.show();
}//if statement ends.
}//onPostExecute ends.
I know this is redundant and maybe a dummy question and asked several times in SO but I’m new to Android therefore I need furthermore help and information regarding such like issues of error encountering.
If you’re encountering this while debugging a stacktrace from a crash, you’ll need to attach the Android source in order to see the code for built-in classes such as
Dialog.java. There are a few tutorials online that show the proper steps, such as this one.EDIT:
The references to the Android source code are out of date in the link that I gave, but you can obtain the relevant Java classes by cloning from the platform_frameworks_base repository on Github.