android背景传感器应用程序与动态计划?

时间:2021-05-22 14:37:04

The whole project consists in making an android application based on crowd sensing that collects data from volunteers (phase 1) and then based on the collected data, every user has a file in the server and the file would be separated into multiple online episodes and I will apply Artificial intelligence algorithms to make the data mining better.

整个项目包括制作基于人群感知的Android应用程序,从志愿者收集数据(第1阶段),然后根据收集的数据,每个用户在服务器中有一个文件,文件将被分成多个在线剧集,我将应用人工智能算法来更好地进行数据挖掘。

For example, if in phase 1 I can determine that the volunteer is usually at home before 8am and he has no valuable information for me to analyse then the application wouldn't even send data to the server. I'm still in phase 1, I'm trying to make an android application that starts running as soon as the user in connected to internet, it would send the data (battery, gps, activity...) to the server and based on the activity (walking, running...) it would determine when the next flow of data is sent. For exemple if he is walking then, the next time the data is sent to the server would be in 5 minutes.

例如,如果在第1阶段,我可以确定志愿者通常在早上8点之前在家,并且他没有有价值的信息供我分析,那么应用程序甚至不会将数据发送到服务器。我还处于第1阶段,我正在尝试制作一个Android应用程序,一旦用户连接到互联网就开始运行,它会将数据(电池,gps,活动......)发送到服务器并基于在活动(行走,跑步......)上,它将确定何时发送下一个数据流。例如,如果他正在行走,则下次将数据发送到服务器将在5分钟内完成。

While searching, I found many solutions on how to make an android application run in the background while keeping sensors collecting full time (high energy consumption) and the better solution would be to have a schedule for example every 5 minutes. What I want to know is, is there an android studio solution to make the schedule dynamic? because it depends on the activity as I said before, so each time it collects information it schedules the next time the information is collected again (the next time we use sensors to collect the data then send it to the server).

在搜索时,我发现了许多关于如何在后台运行Android应用程序同时保持传感器收集全部时间(高能耗)的解决方案,更好的解决方案是例如每5分钟制定一个时间表。我想知道的是,是否有一个Android工作室解决方案,使日程安排动态?因为它取决于我之前所说的活动,所以每次收集信息时,它会在下次再次收集信息时进行安排(下次我们使用传感器收集数据然后将其发送到服务器)。

I hope I made my point clear: what is always running in the background is an application that has a countdown to a specific moment; when that moment arrives the sensors are ON to collect data and send it to the server and that data is also used to make the next countdown (based on the activity data collected) and then the sensor are off until the countdown ends.

我希望我明确指出:在后台运行的是一个具有特定时刻倒计时的应用程序;当那个时刻到来时,传感器开启以收集数据并将其发送到服务器,该数据也用于进行下一次倒计时(基于收集的活动数据),然后传感器关闭,直到倒计时结束。

I would appreciate your suggestions.

我很感激你的建议。

1 个解决方案

#1


0  

Probably the best option for your project is AlarmManager. It can execute your code periodically or at a particular time, samples could be found here. Also the app could be launched by system state event(like wi-fi on/off). To catch these events you need to use BroadcastReceiver, samples are here.

可能是您项目的最佳选择是AlarmManager。它可以定期或在特定时间执行您的代码,可以在此处找到样本。该应用程序也可以由系统状态事件启动(如wi-fi开/关)。要捕获这些事件,您需要使用BroadcastReceiver,样本在这里。

So you don't really need to implement countdown timers or background threads. Moreover manually created countdown background thread could be killed by the system at any time.

所以你真的不需要实现倒计时器或后台线程。此外,系统可以随时杀死手动创建的倒计时后台线程。

#1


0  

Probably the best option for your project is AlarmManager. It can execute your code periodically or at a particular time, samples could be found here. Also the app could be launched by system state event(like wi-fi on/off). To catch these events you need to use BroadcastReceiver, samples are here.

可能是您项目的最佳选择是AlarmManager。它可以定期或在特定时间执行您的代码,可以在此处找到样本。该应用程序也可以由系统状态事件启动(如wi-fi开/关)。要捕获这些事件,您需要使用BroadcastReceiver,样本在这里。

So you don't really need to implement countdown timers or background threads. Moreover manually created countdown background thread could be killed by the system at any time.

所以你真的不需要实现倒计时器或后台线程。此外,系统可以随时杀死手动创建的倒计时后台线程。