android - DialogFragment not showing -


i have problems showing dialogfragment on activity. found lot of other posts issue, couldn't find solution.

this activity:

public class mainactivity extends fragmentactivity {     @override    protected void oncreate(bundle savedinstancestate) {       super.oncreate(savedinstancestate);       setcontentview(r.layout.activity_main);        // check whether data connection 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(), "");       }    < other stuff >    } < other stuff > } 

as can see want display dialog when internet connection not available.

this dialog.

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 builder class 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 {                      < ... >               } catch (exception e) {                  throw new runtimeexception(e.tostring());               }            }         }).setnegativebutton(r.string.cancel,         new dialoginterface.onclicklistener() {            public void onclick(dialoginterface dialog, int id) {               finish();            }         });       // create alertdialog object , return       return builder.create();    }    } 

the strange thing few months ago, dialog appeared. left project , when returned it, after other modifications, found issue.

i'm on 4.0.3 android.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -