简体   繁体   English

在后台Android中运行任务

[英]Running a task in background Android

Warm greetings. 热情的问候。

I am quite new to android currently & had fallen under a fix. 我目前对android很陌生,已经解决了。 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. 问题是我正在运行该应用程序,该应用程序使用HttpPost执行分段上传到远程uri,如果上传失败,则将数据保存到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. 现在,一旦应用程序启动,我的应用程序就会首先查询db&如果有任何未发送的数据,它将首先发送它,然后继续进行。

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. 我正在寻找的功能是可以通过它在后台运行此任务的功能,我无法将这段代码放在onPause中,因为我很少有其他意图可以调用Camera,图像查看器,gps等...任何建议我该如何管理以及如何实现这一目标。 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 PS:-我有在Manifest中定义了一个Activity的应用程序,其他是诸如Camera Intent,Media Player等内置的Broadcaster。仅提供其他信息

Any help will be highly appreciated. 任何帮助将不胜感激。

听起来您需要一项服务: http : //marakana.com/forums/android/examples/60.html

Please check below link for executing the task in bg. 请检查以下链接以执行bg中的任务。

http://developer.android.com/reference/android/os/AsyncTask.html http://developer.android.com/reference/android/os/AsyncTask.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM