在 Android 后台运行任务
热烈的问候。
我目前对 Android 还很陌生&已陷入修复。担心的是我正在运行使用 HttpPost 执行分段上传到远程 uri 的应用程序,如果上传失败,数据将保存到 sqllite。
现在,一旦应用程序启动,我的应用程序就会首先查询数据库和数据库。如果有任何未发送的数据,它首先发送它然后继续。
我正在寻找的是一个功能,通过它我可以在后台运行这个任务,我不能将这段代码放在 onPause 中,因为我几乎没有其他意图来调用相机,图像查看器,gps 等......任何建议我如何管理这个&我怎样才能做到这一点。是否有任何示例/链接可用于这样的实施?
PS:- 我的应用程序在清单中定义了一个活动,其他是内置的广播器,如相机意图、媒体播放器等。只是一个附加信息
任何帮助将不胜感激。
Warm greetings.
I am quite new to android currently & had fallen under a fix. The concern is i am running the app which performs multipart upload to a remote uri using HttpPost, if the upload fails, the data is then saved to sqllite.
Now as soon as the application starts my app firstly queries the db & if there is any unsent data it first send it then proceed ahead.
What i am looking for is a feature via which i can run this task in background, i can not place this peice of code in onPause because i have few other intents which give a call to Camera, image viewer, gps etc... Any suggestions how can i manage this & how can i acheive this. Is there any samples/links available for implementation like this.?
PS:- I have the application with one single Activity defined in Manifest, other are the inbuilt Broadcasters like Camera Intent, Media Player etc. Just an additional info
Any help will be highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来您需要一项服务: http://marakana.com/forums/android/examples /60.html
It sounds like you need a Service: http://marakana.com/forums/android/examples/60.html
请检查以下链接以执行 bg 中的任务。
http://developer.android.com/reference/android/os/AsyncTask.html
Please check below link for executing the task in bg.
http://developer.android.com/reference/android/os/AsyncTask.html