0

I'm moving pieces of my app into a library module for code sharing. From what I've read you can put anything and everything in a library, but I'm suddenly getting WindowLeaked errors any time I try to open a dialog from the library code. I didn't find anything on the web about it. Does anyone know if there's something different you need to do to open dialogs from a library module, or if it just isn't supported? For example, because someone always wants to see code:

AlertDialog.Builder builder = new AlertDialog.Builder(context);
// ...set up the dialog...
final AlertDialog alert = builder.create();
alert.show();
nasch
  • 5,330
  • 6
  • 31
  • 52
  • Where are you calling the Dialog? – devmike01 Jan 22 '19 at 22:00
  • In a utility class. The Context used in is an Activity. – nasch Jan 22 '19 at 22:40
  • Post the part where the Dialog is been used in the utility class. – devmike01 Jan 23 '19 at 06:48
  • If I understand you, that code is posted above. If you mean something else, could you clarify? – nasch Jan 23 '19 at 15:21
  • What I meant is the function that's triggering the above code. – devmike01 Jan 23 '19 at 15:24
  • It's not very interesting. From an Activity in the app module (not the library): `dialogUtils.reportError(this, R.string.error_referral_code);` which goes through a chain of method calls to end up with the code I posted in the question. – nasch Jan 23 '19 at 15:39
  • I restarted the whole project of converting to a library module and dialogs are working now so I guess this one will remain a mystery. – nasch Jan 26 '19 at 17:41

0 Answers0