Display.getInstance().execute on android causes OS to suspend my app

31 views
Skip to first unread message

shop.servic...@gmail.com

unread,
Feb 16, 2019, 11:26:50 AM2/16/19
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA NetBeans 8.2
Desktop OS Windows 10 Pro
Simulator Latest
Device Android 7 & 8.1

My app uses Display.getInstance().execute(file system path to PDF doc)

On Android, my app receives a suspend signal from the OS until I close the PDF reader app.
Once the PDF reader app is closed, my app receives a start()

This does not occur on IOS,

Curious, Is there a method that my app can envoke another process and not suspend my app?

Thoughts?

Shai Almog

unread,
Feb 17, 2019, 12:28:17 AM2/17/19
to CodenameOne Discussions
This is a core difference between the OS's. In some cases we hide those differences but in lifecycle it's really hard/undesireable to do so.
Android is very aggressive about activity lifecycle. It suspends instantly, even does that on device rotation by default (we hide that behavior). However, we don't know if you might press the home button from the PDF viewer so we can't "fake it" as we won't get another stop() event.

shop.servic...@gmail.com

unread,
Feb 17, 2019, 8:12:23 AM2/17/19
to CodenameOne Discussions
Thanks.

Mark Bolduc

unread,
Feb 9, 2020, 3:04:34 PM2/9/20
to CodenameOne Discussions
So , 1 year later, In Android 9

Can An App run an external process / app without the OS sending a suspend to my app?

Is there a codenameone PDF reader library?

Regards

Shai Almog

unread,
Feb 9, 2020, 8:52:22 PM2/9/20
to CodenameOne Discussions
No. When you exit the app the process is always suspended that's how mobile programming works.
Notice the PDF reader logic works perfectly you just receive a suspend/resume for the current activity.

Mark Bolduc

unread,
Feb 11, 2020, 6:24:07 PM2/11/20
to CodenameOne Discussions
Note that this is only on Android, IOS does not suspend my app when my app spawns another process like reading a PDF document.

Regards.

Shai Almog

unread,
Feb 11, 2020, 9:10:26 PM2/11/20
to CodenameOne Discussions
iOS would do that for some processes. Android is more consistent in that sense. You should code defensively regardless.
FYI Android does that when you just rotate the device... We hide a lot of these nuances from the developers but there are some things that aren't abstractable.

Mark Bolduc

unread,
Feb 12, 2020, 7:55:46 AM2/12/20
to CodenameOne Discussions
Fair enough.

thanks.

Do you think this behaviour will go away when these devices have more processing power?

Regards.

Mark Bolduc

unread,
Feb 12, 2020, 3:36:26 PM2/12/20
to CodenameOne Discussions

Shai Almog

unread,
Feb 13, 2020, 9:28:32 PM2/13/20
to CodenameOne Discussions
No. It's core to their architecture.
It's about battery life and control.

Notice your app still has CPU access if it needs it. This isn't about that.
Reply all
Reply to author
Forward
0 new messages