jmpessoa / lazandroidmodulewizard

LAMW: Lazarus Android Module Wizard: Form Designer and Components development model!
246 stars 82 forks source link

Please try to add foreground service support #480

Open JanuszChmiel opened 1 year ago

JanuszChmiel commented 1 year ago

Dear elite programmers, who are concentrated around this excellent package. Does somebody of us think, that there is any chance to allow Android foreground services creation? Unfortunately, Android newer than 6.0 have more and more power management features, which in fact do not allow background tasks running if screen is turned off. It is not so simple to overcome those modern power management features of Android. The most reliable procedure is to use Foreground service with notification text and with some button on notification area. In such case, if notification is interactive Android will not very probably kill such app. Unfortunately, simply creating Android foreground service with only non interactive notification message on notification tray is not enough. Notification must contain some button, such as Stop The app or to switch some apps function. So core of Android will do not allow such app to autoterminate. Very deep Java programming knowledge is required to extend special Java templates, which are communicating with .so compiled native .so library compiled by Free Pascal compiler. The question is, if is it even possible to combine JNI with foreground service? Thank you very very much for your programmers thinkink. It is not easy task, but very important for new Android releases.