0

I want to display an alert from a service and I don't care what activity currently is, just display an alert.

But the builder need construction like

AlertDialog.Builder builder = new AlertDialog.Builder(this);

But how I know the current activity and pass to the AlertDialog.Builder?

Ryan
  • 10,191
  • 23
  • 85
  • 145

1 Answers1

1

But how I know the current activity and pass to the AlertDialog.Builder?

You dont need to know the current activity. Just start an activity with android:theme="@android:style/Theme.Dialog" theme from the service.

Ronnie
  • 24,023
  • 8
  • 54
  • 95
  • That's fine, but using `Theme.Dialog`, I have an empty dialog with title, is it possible to hide them so I can create `AlertDialog.Builder` inside the `onCreate` of the new activity. THanks. – Howard Aug 04 '12 at 16:44
  • No need of the AlertDialog.Builder... set the content of activity.. layout will have a textView and 1-2 buttons.. – Ronnie Aug 04 '12 at 17:14