Xamarin Froms The program does not work well in the background.

Ilim Gusseinov 81 Reputation points
2022-04-27T03:31:47.207+00:00

Hello everyone. I have a problem with my program, it uses Essentials: Accelerometer to count the number of slopes of the device.But the problem is that it sometimes does not work or sometimes it works but not stably when the phone is in the background or when the screen is locked.The program also uses Essentials: Vibration, which also does not work or does not work stably in the background or in the mode with the screen locked. Please help solve this problem of stable operation of the program in the background. Thanks !!!

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,367 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 77,181 Reputation points Microsoft Vendor
    2022-04-27T07:39:30.77+00:00

    Hello,​

    For Android, you can use Essentials: Accelerometer in the Service, due to the background service limitation in android 8.0 or later. You can try to create a Foreground Service, then run Essentials: Accelerometer in foreground service.

    Foreground service will push a notification in the foreground, it will keep your application running in the background, your application will not be killed or hang easily.

    For iOS, you can register your application to run in the Background, please notice: your application should fall into approved categories.

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Ilim Gusseinov 81 Reputation points
    2022-05-03T10:50:48.103+00:00

    I tested the program with background services, but it did not give the desired result.Here is my code on github // https://github.com/Ilim-Hussein/MyMobilProject // I have compiled a test sample of the program. Can you see if everything is correct?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.