Android 应用程序组件 - 需要一点建议

发布于 2024-08-07 23:58:43 字数 457 浏览 6 评论 0原文

我是 Android 开发的新手;

基本上,我将编写一个应用程序,让用户拍照,并将照片(带有一堆额外数据)提交到远程 Web 服务。

所以我猜我需要:

  1. 一个拍照应用程序(活动),它将收集所有额外的数据并放入 SQLite 数据库中。
  2. 后台服务按时间间隔查找数据库并通过互联网发送数据,可以选择使用当前 GPS 位置发出网络请求(我试图记住,有时网络无法访问)。
  3. 一个接收器对象,它将在启动时运行服务,并可选择检查服务是否需要重新启动。

我担心的是:

  1. 我真的需要监控服务并关心任何可能会终止服务的不良情况吗?
  2. 在不间断运行服务的情况下,电池能否持续至少 12 小时,每隔 30 分钟进行一些网络/GPS 操作? (G1/Dream)
  3. 还有什么要注意的吗?

任何想法/建议将不胜感激。

I am a complete newbie to Android development;

Basically, I am about to write an application, that will let the user to take photo, which (with a bunch of extra data) will be submitted to the remote webservice.

So I'm guessing I will need:

  1. A Photo-taking application (Activity) that will gather all the extra data and put in the SQLite DB.
  2. A background service looking up the DB in time intervals and sending the data over the Internet, optionally making web requests with current GPS location (I'm trying to keep in mind, that sometimes network would not be accessible).
  3. A receiver object that will run the service at boot, and optionally check if the service needs to be restarted.

My concerns are:

  1. Do I really need to monitor the service and care about anything bad that could kill it.
  2. Will the battery last for at least 12 hours with a non-stop running service, making some networking/GPS actions in, let's say, 30-minute intervals. (G1/Dream)
  3. What else should I be careful about?

Any ideas/suggestions will be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

韬韬不绝 2024-08-14 23:58:43

需要一点建议

Rutabaga

哦,等等。您可能正在寻找与 Android 相关的内容。好的,继续。

将运行的接收器对象
启动时服务,并可选择检查
是否需要重启服务。

恶心。使用 AlarmManager 并使您的服务行为 更像是一个 cron 作业/Windows 计划任务。

我真的需要监控吗
服务和关心有什么不好的
这可能会杀死它。

如果您使用 AlarmManager 并让您的服务表现得更像 cron 作业,则不会。

电池能持续至少 12 小时吗?
小时不间断运行的服务,
进行一些网络/GPS 操作,
假设间隔 30 分钟。
(G1/梦想)

如果您使用 AlarmManager 并且让您的服务表现得更像 cron 作业,则 30 分钟的间隔应该没问题。使用完毕后请确保关闭 GPS 无线电。请注意,从 cron 作业类型的任务中使用 GPS 无线电有点棘手,因为需要一段时间才能获得第一次修复。您还需要了解如何使用 PowerManager.WakeLock 使设备保持唤醒状态,直到您的工作完成。

我还应该注意什么?

我的天,驼鹿咬伤可以是漂亮的。

除此之外和我写的如上所述,您应该处于良好的状态。请注意,您正在深入研究的内容并不完全是“新手”材料。

a word of advice needed

Rutabaga.

Oh, wait. You're probably looking for something related to Android. OK, carry on.

A receiver object that will run the
service at boot, and optionally check
if the service needs to be restarted.

Yuck. Use AlarmManager and have your service behave more like a cron job/Windows scheduled task.

Do I really need to monitor the
service and care about anything bad
that could kill it.

Not if you use AlarmManager and have your service behave more like a cron job.

Will the battery last for at least 12
hours with a non-stop running service,
making some networking/GPS actions in,
let's say, 30-minute intervals.
(G1/Dream)

If you use AlarmManager and have your service behave more like a cron job, a 30-minute interval should be OK. Just make sure you shut down the GPS radio when you are done with it. Note that using the GPS radio from a cron job sort of task is a bit tricky, since it takes a while to get its first fix. You will also want to take a look at using PowerManager.WakeLock to keep the device awake until your work is completed.

What else should I be careful about?

Mynd you, moose bites kan be pretti nasti.

Beyond that and what I wrote above, you should be in OK shape. Note that what you are diving into is not exactly "newbie" material.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文