0

I want to show dialog/popup when application in kill state and BroadcastReceiver receive any action.

MyReceiver.java

public class MyReceiver extends BroadcastReceiver {
   @Override
   public void onReceive(Context context, Intent intent) {
       MyDialog.showDialog(context);
   }
}

I have added permission in manifest.

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

I am getting exception when activity foreground

Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

style.xml

<style name="AppTheme" parent="Theme.AppCompat.Light">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

My dialog is not display in activity kill state but receiver is called.

  • Before you think further . have a look into [This answer](https://stackoverflow.com/a/7918720/4168607) . And if you still wanna go with dialog then [This answer](https://stackoverflow.com/a/19269931/4168607) will help .Thx – ADM Dec 08 '17 at 05:11
  • I have tried but dialog is not show in foreground and kill state. – user8269038 Dec 08 '17 at 05:16
  • If you read the first link, as its says it goes against Android design and UI guidelines then why don't you go with a Notification or a Activity with dialog theme. Its better if your app follow the guidelines and don't irritate user by a random popUp on screen. – ADM Dec 08 '17 at 05:23
  • Suppose you are making an app for client and you have to implement these type of things then you told them `it goes against Android design and UI guidelines`. – user8269038 Dec 08 '17 at 05:30
  • Yeah definitely.why not . Guidelines made by the technology for user experience, not by the client. Good bye – ADM Dec 08 '17 at 05:32
  • either client will be free to you or company will because it is done in other apps – user8269038 Dec 08 '17 at 05:35

1 Answers1

-2

Actually, in this case, or without an activity, you can't launch any kind of dialog.

1. First method

create a dialog activity : How to make dialog activity

2. Second

create popup window: How to make a simple android popup window?

Edit

If the application is not in the foreground, please don't do this. Go for notification

cincy_anddeveloper
  • 1,140
  • 1
  • 9
  • 19
noobEinstien
  • 3,147
  • 4
  • 24
  • 42