Note that there are some explanatory texts on larger screens.

plurals
  1. PODialogFragment not showing
    primarykey
    data
    text
    <p>I have problems showing a DialogFragment on an activity. I found a lot of other posts about this issue, but I couldn't find a solution.</p> <p>This is my Activity:</p> <pre><code>public class MainActivity extends FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // check whether data connection is available ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo == null || !netInfo.isConnectedOrConnecting()) { DataConnectionUnavailableDialog dialog = DataConnectionUnavailableDialog .newInstance("R.string.connection_unavailable"); dialog.show(getFragmentManager(), ""); } &lt; other stuff &gt; } &lt; other stuff &gt; } </code></pre> <p>As you can see I want to display a dialog when Internet connection is not available.</p> <p>This is my dialog.</p> <pre><code>public class DataConnectionUnavailableDialog extends DialogFragment { static DataConnectionUnavailableDialog newInstance(String title) { DataConnectionUnavailableDialog f = new DataConnectionUnavailableDialog(); Bundle args = new Bundle(); args.putString("title", title); f.setArguments(args); return f; } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(R.string.connection_unavailable).setPositiveButton( R.string.open_connection, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { try { &lt; ... &gt; } catch (Exception e) { throw new RuntimeException(e.toString()); } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finish(); } }); // Create the AlertDialog object and return it return builder.create(); } } </code></pre> <p>The strange thing is that few months ago, the dialog appeared. Then I left the project and when I returned to it, after some other modifications, I found this issue.</p> <p>I'm on a 4.0.3 Android.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload