Created
December 6, 2017 10:28
-
-
Save sreelallalu/d4e31e5573fa3f71b28681fe080a2af2 to your computer and use it in GitHub Desktop.
AlertDialogBox_Onservice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Need Activity for display AlertDialog, because we can't display Dialog from any Service | |
Solution. | |
Create Activity as Dialog Theme and start that Activity from Service. | |
Just need to register you Activity in menifest.xml like as below | |
android:theme="@android:style/Theme.Dialog" | |
or | |
android:theme="@android:style/Theme.Translucent.NoTitleBar" | |
MyDialog.java | |
public class MyDialog extends Activity { | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
final AlertDialog alertDialog = new AlertDialog.Builder(this).create(); | |
alertDialog.setTitle("your title"); | |
alertDialog.setMessage("your message"); | |
alertDialog.setIcon(R.drawable.icon); | |
alertDialog.show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment