Crash app when show ProgressDialog. I'm testing on my phone with a slide-out keyboard. When dialog is show I slide keyboard and app crashes.
public static class ProgressDialogFragment extends DialogFragment
{
public ProgressDialogFragment()
{
super();
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
final ProgressDialog dialog = new ProgressDialog(getActivity());
dialog.setMessage(getString(R.string.dlg_progress_title));
dialog.setIndeterminate(true);
dialog.setCancelable(false);
return dialog;
}
@Override
public void show(FragmentManager manager, String tag)
{
try
{
super.show(manager, tag);
}
catch (IllegalStateException e)
{
Log.d(TAG, e.getMessage());
}
}
}
Crash log:
> 04-25 20:49:46.999: E/AndroidRuntime(7904): FATAL EXCEPTION: main
04-25 20:49:46.999: E/AndroidRuntime(7904): java.lang.NullPointerException
04-25 20:49:46.999: E/AndroidRuntime(7904): at android.support.v4.app.DialogFragment.dismissInternal(DialogFragment.java:184)
04-25 20:49:46.999: E/AndroidRuntime(7904): at android.support.v4.app.DialogFragment.dismissAllowingStateLoss(DialogFragment.java:165)
04-25 20:49:46.999: E/AndroidRuntime(7904): at com.fisherman.activity.HomeActivity$2.onPostExecute(HomeActivity.java:268)
04-25 20:49:46.999: E/AndroidRuntime(7904): at com.fisherman.activity.HomeActivity$2.onPostExecute(HomeActivity.java:1)
04-25 20:49:46.999: E/AndroidRuntime(7904): at android.os.AsyncTask.finish(AsyncTask.java:417)
04-25 20:49:46.999: E/AndroidRuntime(7904): at android.os.AsyncTask.access$300(AsyncTask.java:127)
04-25 20:49:46.999: E/AndroidRuntime(7904): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
04-25 20:49:46.999: E/AndroidRuntime(7904): at android.os.Handler.dispatchMessage(Handler.java:99)
04-25 20:49:46.999: E/AndroidRuntime(7904): at android.os.Looper.loop(Looper.java:130)
04-25 20:49:46.999: E/AndroidRuntime(7904): at android.app.ActivityThread.main(ActivityThread.java:3835)
04-25 20:49:46.999: E/AndroidRuntime(7904): at java.lang.reflect.Method.invokeNative(Native Method)
04-25 20:49:46.999: E/AndroidRuntime(7904): at java.lang.reflect.Method.invoke(Method.java:507)
04-25 20:49:46.999: E/AndroidRuntime(7904): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
04-25 20:49:46.999: E/AndroidRuntime(7904): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
04-25 20:49:46.999: E/AndroidRuntime(7904): at dalvik.system.NativeStart.main(Native Method)
I've done class is static because app crash:
> 04-25 20:48:50.757: E/AndroidRuntime(7863): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.fisherman.activity.HomeActivity$ProgressDialogFragment: make sure class name exists, is public, and has an empty constructor that is public
04-25 20:48:50.757: E/AndroidRuntime(7863): at android.support.v4.app.Fragment.instantiate(Fragment.java:405)
04-25 20:48:50.757: E/AndroidRuntime(7863): at android.support.v4.app.FragmentState.instantiate(Fragment.java:97)
04-25 20:48:50.757: E/AndroidRuntime(7863): at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1767)
04-25 20:48:50.757: E/AndroidRuntime(7863): at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:208)
04-25 20:48:50.757: E/AndroidRuntime(7863): at com.fisherman.activity.HomeActivity.onCreate(HomeActivity.java:50)
04-25 20:48:50.757: E/AndroidRuntime(7863): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-25 20:48:50.757: E/AndroidRuntime(7863): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
04-25 20:48:50.757: E/AndroidRuntime(7863): ... 12 more
04-25 20:48:50.757: E/AndroidRuntime(7863): Caused by: java.lang.InstantiationException: com.fisherman.activity.HomeActivity$ProgressDialogFragment
04-25 20:48:50.757: E/AndroidRuntime(7863): at java.lang.Class.newInstanceImpl(Native Method)
04-25 20:48:50.757: E/AndroidRuntime(7863): at java.lang.Class.newInstance(Class.java:1409)
04-25 20:48:50.757: E/AndroidRuntime(7863): at android.support.v4.app.Fragment.instantiate(Fragment.java:394)