This chunk of code that puts up an alert dialog box is causing my app to crash on my mobile phone when I try to run it.
Why?
Is the issue because I am trying to put up the alert dialog box on onCreate()?
Why?
Is the issue because I am trying to put up the alert dialog box on onCreate()?
Code:
public void onCreate()
{
super.onCreate();
//for (int nI = 0; nI < m_nMaxStations; nI++)
// m_arrayStations[nI] = new CStation(nI + 1);
AlertDialog.Builder builder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
{
builder = new AlertDialog.Builder(this, android.R.style.Theme_Material_Dialog_Alert);
}
else
{
builder = new AlertDialog.Builder(this);
}
builder.setTitle("Delete entry");
builder.setMessage("Are you sure you want to delete this entry?");
builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
// continue with delete
}
});
builder.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
// do nothing
}
});
builder.setIcon(android.R.drawable.ic_dialog_alert);
builder.show();
//GetSettings();
//Dump();
}