Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

showDialog deprecated. What's the alternative?

Tags:

android

dialog

Is there something else that should be called?

showDialog(TIME_DIALOG_ID); 

It's in this tutorial but says deprecated in Eclipse.

like image 542
Denis Avatar asked Apr 23 '12 17:04

Denis


People also ask

What can I use instead of progress dialog?

"Deprecated" refers to functions or elements that are in the process of being replaced by newer ones. ProgressDialog is a modal dialog, which prevents the user from interacting with the app. Instead of using this class, you should use a progress indicator like ProgressBar , which can be embedded in your app's UI.

Why is ProgressDialog deprecated?

because It prevents the user to interact with the app. Let me explain to you why this is bad. As we show the Progress Dialog It runs and blocks the UI and user can't interact with the App.

How do you show DialogFragment?

Showing the DialogFragment It is not necessary to manually create a FragmentTransaction to display your DialogFragment . Instead, use the show() method to display your dialog. You can pass a reference to a FragmentManager and a String to use as a FragmentTransaction tag.


2 Answers

From http://developer.android.com/reference/android/app/Activity.html

public final void showDialog (int id) Added in API level 1

This method was deprecated in API level 13. Use the new DialogFragment class with FragmentManager instead; this is also available on older platforms through the Android compatibility package.

Simple version of showDialog(int, Bundle) that does not take any arguments. Simply calls showDialog(int, Bundle) with null arguments.

Why

  • A fragment that displays a dialog window, floating on top of its activity's window. This fragment contains a Dialog object, which it displays as appropriate based on the fragment's state. Control of the dialog (deciding when to show, hide, dismiss it) should be done through the API here, not with direct calls on the dialog.
  • Here is a nice discussion Android DialogFragment vs Dialog
  • Another nice discussion DialogFragment advantages over AlertDialog

How to solve?

  • http://android-developers.blogspot.in/2012/05/using-dialogfragments.html

More

  • http://developer.android.com/guide/topics/fundamentals/fragments.html
  • http://developer.android.com/training/basics/fragments/index.html
like image 89
Md Mahbubur Rahman Avatar answered Oct 20 '22 01:10

Md Mahbubur Rahman


From Activity#showDialog(int):

This method is deprecated.
Use the new DialogFragment class with FragmentManager instead; this is also available on older platforms through the Android compatibility package.

like image 31
Matt Ball Avatar answered Oct 19 '22 23:10

Matt Ball