I'm in WidgetProvider where I got in such way. The only thing I've is context. And I need to show DialogFragment. To show it, I need to get FragmentManger, but where can I get it if I don't have activity?
Asked
Active
Viewed 92 times
2 Answers
0
That is not possible. Fragments and dialogs have to be shown by an Activity
. Call startActivity()
to start up an activity that will show your DialogFragment
.

CommonsWare
- 986,068
- 189
- 2,389
- 2,491
-
Can this activity be invisible? – kandi Jul 16 '15 at 11:28
-
2It's probably better that you create an Activity with a Dialog theme instead. – BladeCoder Jul 16 '15 at 11:28
-
@danpetruk: I have never tried using `Theme.NoDisplay` with an activity that attempts to show a `DialogFragment` as a dialog. That might work. Otherwise, as BladeCoder suggests, you can create an activity that has a `...Dialog` theme, so that it will not fill the screen. – CommonsWare Jul 16 '15 at 11:31
-
@BladeCoder I wanted to do this, but http://stackoverflow.com/questions/31430665/how-to-make-square-or-round-floating-activity – kandi Jul 16 '15 at 11:54
-
1@danpetruk You can for example extend `Theme.AppCompat.Dialog`and customize it. Take a look at AppCompat's theme files to see how they customized the design to provide a Material look on older Android versions. – BladeCoder Jul 16 '15 at 12:15
0
create a class which extends activity in onCreate create a dialog and startActivity.
Intent dialog = new Intent(context, Your_dialog.class);
dialog.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(dialog);

Bilal Shahid
- 490
- 9
- 16