New dialog activity not starting in Android -


i have activity, starts dialog box when list item long pressed. start activity via code snippet:

private void showwifisettings(int arg2) {                 intent newintent = new intent("com.example.searchingwifi.dialogactivity");                 startactivity(newintent);                 } 

and, code in new dialog activity undersigned.

package com.example.searchingwifi;  import android.app.alertdialog; import android.app.dialog; import android.content.dialoginterface; import android.os.bundle; import android.support.v4.app.dialogfragment; import android.view.layoutinflater;  public class dialogactivity extends dialogfragment{       @override     public dialog oncreatedialog(bundle savedinstancestate) {         alertdialog.builder builder = new alertdialog.builder(getactivity());         // layout inflater         layoutinflater inflater = getactivity().getlayoutinflater();          // inflate , set layout dialog         // pass null parent view because going in dialog layout         builder.setview(inflater.inflate(r.layout.dialog, null));           return builder.create();     } } 

on long pressing corresponding list item, logcat gives me following error, , application stops running.

06-27 12:54:22.150: e/androidruntime(25118): fatal exception: main 06-27 12:54:22.150: e/androidruntime(25118): process: com.example.searchingwifi, pid: 25118 06-27 12:54:22.150: e/androidruntime(25118): java.lang.runtimeexception: unable instantiate activity componentinfo{com.example.searchingwifi/com.example.searchingwifi.dialogactivity}: java.lang.classcastexception: com.example.searchingwifi.dialogactivity cannot cast android.app.activity 06-27 12:54:22.150: e/androidruntime(25118):    @ android.app.activitythread.performlaunchactivity(activitythread.java:2121) 06-27 12:54:22.150: e/androidruntime(25118):    @ android.app.activitythread.handlelaunchactivity(activitythread.java:2245) 06-27 12:54:22.150: e/androidruntime(25118):    @ android.app.activitythread.access$800(activitythread.java:135) 06-27 12:54:22.150: e/androidruntime(25118):    @ android.app.activitythread$h.handlemessage(activitythread.java:1196) 06-27 12:54:22.150: e/androidruntime(25118):    @ android.os.handler.dispatchmessage(handler.java:102) 06-27 12:54:22.150: e/androidruntime(25118):    @ android.os.looper.loop(looper.java:136) 06-27 12:54:22.150: e/androidruntime(25118):    @ android.app.activitythread.main(activitythread.java:5017) 06-27 12:54:22.150: e/androidruntime(25118):    @ java.lang.reflect.method.invokenative(native method) 06-27 12:54:22.150: e/androidruntime(25118):    @ java.lang.reflect.method.invoke(method.java:515) 06-27 12:54:22.150: e/androidruntime(25118):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) 06-27 12:54:22.150: e/androidruntime(25118):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) 06-27 12:54:22.150: e/androidruntime(25118):    @ dalvik.system.nativestart.main(native method) 06-27 12:54:22.150: e/androidruntime(25118): caused by: java.lang.classcastexception: com.example.searchingwifi.dialogactivity cannot cast android.app.activity 06-27 12:54:22.150: e/androidruntime(25118):    @ android.app.instrumentation.newactivity(instrumentation.java:1061) 06-27 12:54:22.150: e/androidruntime(25118):    @ android.app.activitythread.performlaunchactivity(activitythread.java:2112) 06-27 12:54:22.150: e/androidruntime(25118):    ... 11 more 

can me error, , making mistake ?

edit :- if starting new dialog activity, system still giving error. logcat given below.

06-30 03:54:10.550: e/androidruntime(1175): fatal exception: main 06-30 03:54:10.550: e/androidruntime(1175): process: com.example.testingdialog, pid: 1175 06-30 03:54:10.550: e/androidruntime(1175): java.lang.runtimeexception: unable instantiate activity componentinfo{com.example.testingdialog/com.example.testingdialog.mainactivity}: java.lang.classcastexception: com.example.testingdialog.mainactivity cannot cast android.app.activity 06-30 03:54:10.550: e/androidruntime(1175):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2121) 06-30 03:54:10.550: e/androidruntime(1175):     @ android.app.activitythread.handlelaunchactivity(activitythread.java:2245) 06-30 03:54:10.550: e/androidruntime(1175):     @ android.app.activitythread.access$800(activitythread.java:135) 06-30 03:54:10.550: e/androidruntime(1175):     @ android.app.activitythread$h.handlemessage(activitythread.java:1196) 06-30 03:54:10.550: e/androidruntime(1175):     @ android.os.handler.dispatchmessage(handler.java:102) 06-30 03:54:10.550: e/androidruntime(1175):     @ android.os.looper.loop(looper.java:136) 06-30 03:54:10.550: e/androidruntime(1175):     @ android.app.activitythread.main(activitythread.java:5017) 06-30 03:54:10.550: e/androidruntime(1175):     @ java.lang.reflect.method.invokenative(native method) 06-30 03:54:10.550: e/androidruntime(1175):     @ java.lang.reflect.method.invoke(method.java:515) 06-30 03:54:10.550: e/androidruntime(1175):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) 06-30 03:54:10.550: e/androidruntime(1175):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) 06-30 03:54:10.550: e/androidruntime(1175):     @ dalvik.system.nativestart.main(native method) 06-30 03:54:10.550: e/androidruntime(1175): caused by: java.lang.classcastexception: com.example.testingdialog.mainactivity cannot cast android.app.activity 06-30 03:54:10.550: e/androidruntime(1175):     @ android.app.instrumentation.newactivity(instrumentation.java:1061) 06-30 03:54:10.550: e/androidruntime(1175):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2112) 06-30 03:54:10.550: e/androidruntime(1175):     ... 11 more 

you trying start activity dialogfragment. either make dialogactivity , start activity this:

intent intent=new intent(getapplicationcontext(), dialogactivity.class); startactivity(intent); 

or

you can keep dialogragment only, , show dialogfragment instead of starting new activity.

example:

mydialogfragment mydialogfragment = new mydialogfragment(); mydialogfragment.show(fragmanager, "mydialogfragment"); 

reference links:

dialog fragment example

dialog activity example


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -