I am currently working on an android project and I am having an issue when the user presses the back button on an activity that uses the dialog theme.
Basically I have an activity, lets call it MyActivity and a second activity which uses the @android:style/Theme.Holo.Dialog called MyDialog.
When the MyDialog activity is shown on the screen, the activity dialogue starts up as expected in a dialogue, but when the user presses the back button, the dialog activity closes as is expected, but the starting activity i.e. MyActivity seems to finish, I just get a blank screen.
I’m not setting any flags for starting the activity so I don’t understand why it is doing this behaviour. Below is the code that I am using to start the dialog activity.
public OnItemClickListener mListView = new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View view, int position,
long id) {
String selection = ((TextView)view).getText().toString();
StringTokenizer st = new StringTokenizer(selection, "\n");
String name = st.nextToken();
String username = st.nextToken();
Intent intent = new Intent(PasswordList.this, LoginSelectionManager.class);
intent.putExtra("name", name);
intent.putExtra("username", username);
startActivity(intent);
}
};
UPDATE
As request below is the code of the onResume method of MyActivity
@Override
public void onResume()
{
super.onResume();
populateListArray();
}
All this is doing is call a function that repopulates the ListView array adapter with data from the database. Below is the code for this
private void populateListArray()
{
ArrayList<Spanned> passwords = managePasswordList.getPasswordList();
if (passwords != null)
{
passwordArrayAdapter = new ArrayAdapter<Spanned>(this,
android.R.layout.simple_list_item_1, passwords);
setListAdapter(passwordArrayAdapter);
passwordArrayAdapter.setNotifyOnChange(true);
myListView.setTextFilterEnabled(true);
}
}
Put logs in
onFinishof both the activities and see which ones actually finish… I doubt the dialog activity finishes on pressing back..The fact that you get a blank screen means your activity has not finished yet, its just that the listview is empty.
So the next question that arises is why your passwords list is null in the
onResume. Do you really need to set the adapter in theonResume? See moving it toonCreate..