How to use AsyncTask in a different process?
I'm using a Service in different process of my app using android:process=":MyService"
and I recognized that my AsyncTasks in MyService class doesn't work and execute, so how can I sync my datas with my Server in MyService class?
I just want to update my Server from this class cause it's a ForegroundService that should be active most of the times. I believe that defining MyService class as a separate process helps my app's battery usage. I've already defined an inner class and used it inside MyService class but it doesn't work at all, I also tried to use another custom asyncTask class Object in MyService class but it doesn't work either
here's an example of my code in MyService class:
static class UpdatePoint extends AsyncTask<String,String,String>{
@Override
protected String doInBackground(String... strings) {
String userId = user.get(SessionManager.getKeyId()).toString();
String coin = strings[1];
String step = strings[2];
String log_lat = strings[3];
String log_lng = strings[4];
String log_zone = strings[5];
String log_address = strings[6];
//Log.d("updatePoint","coin:"+coin+", step:"+step);
try {
String update_point_url = "http://mohregroup.ir/db-mapapa/updatePoint.php";
URL url = new URL(update_point_url);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setConnectTimeout(5*1000);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
OutputStream outputStream = httpURLConnection.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
String data = URLEncoder.encode("userId", "UTF-8") + "=" + URLEncoder.encode(userId, "UTF-8")
+ "&" + URLEncoder.encode("coin", "UTF-8") + "=" + URLEncoder.encode(coin, "UTF-8")
+ "&" + URLEncoder.encode("step", "UTF-8") + "=" + URLEncoder.encode(step, "UTF-8")
+ "&" + URLEncoder.encode("log_lat", "UTF-8") + "=" + URLEncoder.encode(log_lat, "UTF-8")
+ "&" + URLEncoder.encode("log_lng", "UTF-8") + "=" + URLEncoder.encode(log_lng, "UTF-8")
+ "&" + URLEncoder.encode("log_zone", "UTF-8") + "=" + URLEncoder.encode(log_zone, "UTF-8")
+ "&" + URLEncoder.encode("log_address", "UTF-8") + "=" + URLEncoder.encode(log_address, "UTF-8");
bufferedWriter.write(data);
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
InputStream inputStream = httpURLConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "iso-8859-1"));
StringBuilder response = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
response.append(line);
}
//Log.d("updatePoints response:", response.toString().trim());
bufferedReader.close();
inputStream.close();
httpURLConnection.disconnect();
Timber.d("done Successfully!");
return response.toString();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
and using it inside another method of MyService class :
if (getAddress() != null) {
if (getAddress().getFeatureName() == null &&
getAddress().getAddressLine(0) != null) {
new UpdatePoint().execute(String.valueOf(coins),
String.valueOf(steps),
String.valueOf(originLocation.getLatitude()),
String.valueOf(originLocation.getLongitude()),
getAddress().getFeatureName(), "not titled");
} else if (getAddress().getFeatureName() != null &&
getAddress().getAddressLine(0) == null) {
new UpdatePoint().execute(String.valueOf(coins),
String.valueOf(steps),
String.valueOf(originLocation.getLatitude()),
String.valueOf(originLocation.getLongitude()),
"not titled", getAddress().getAddressLine(0));
} else {
new UpdatePoint().execute(String.valueOf(coins), String.valueOf(steps),
String.valueOf(originLocation.getLatitude()), String.valueOf(originLocation.getLongitude()),
getAddress().getFeatureName(), getAddress().getAddressLine(0));
}
} else {
new UpdatePoint().execute(String.valueOf(coins), String.valueOf(steps),
String.valueOf(originLocation.getLatitude()), String.valueOf(originLocation.getLongitude()),
"not titled", "not titled");
}
So, any Ideas about
how to use an asyncTask in a service with different process?
or
any other way in order to update the server from a service with different process?
any helps would be appreciated a lot!
Thanks.

add a comment |
I'm using a Service in different process of my app using android:process=":MyService"
and I recognized that my AsyncTasks in MyService class doesn't work and execute, so how can I sync my datas with my Server in MyService class?
I just want to update my Server from this class cause it's a ForegroundService that should be active most of the times. I believe that defining MyService class as a separate process helps my app's battery usage. I've already defined an inner class and used it inside MyService class but it doesn't work at all, I also tried to use another custom asyncTask class Object in MyService class but it doesn't work either
here's an example of my code in MyService class:
static class UpdatePoint extends AsyncTask<String,String,String>{
@Override
protected String doInBackground(String... strings) {
String userId = user.get(SessionManager.getKeyId()).toString();
String coin = strings[1];
String step = strings[2];
String log_lat = strings[3];
String log_lng = strings[4];
String log_zone = strings[5];
String log_address = strings[6];
//Log.d("updatePoint","coin:"+coin+", step:"+step);
try {
String update_point_url = "http://mohregroup.ir/db-mapapa/updatePoint.php";
URL url = new URL(update_point_url);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setConnectTimeout(5*1000);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
OutputStream outputStream = httpURLConnection.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
String data = URLEncoder.encode("userId", "UTF-8") + "=" + URLEncoder.encode(userId, "UTF-8")
+ "&" + URLEncoder.encode("coin", "UTF-8") + "=" + URLEncoder.encode(coin, "UTF-8")
+ "&" + URLEncoder.encode("step", "UTF-8") + "=" + URLEncoder.encode(step, "UTF-8")
+ "&" + URLEncoder.encode("log_lat", "UTF-8") + "=" + URLEncoder.encode(log_lat, "UTF-8")
+ "&" + URLEncoder.encode("log_lng", "UTF-8") + "=" + URLEncoder.encode(log_lng, "UTF-8")
+ "&" + URLEncoder.encode("log_zone", "UTF-8") + "=" + URLEncoder.encode(log_zone, "UTF-8")
+ "&" + URLEncoder.encode("log_address", "UTF-8") + "=" + URLEncoder.encode(log_address, "UTF-8");
bufferedWriter.write(data);
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
InputStream inputStream = httpURLConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "iso-8859-1"));
StringBuilder response = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
response.append(line);
}
//Log.d("updatePoints response:", response.toString().trim());
bufferedReader.close();
inputStream.close();
httpURLConnection.disconnect();
Timber.d("done Successfully!");
return response.toString();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
and using it inside another method of MyService class :
if (getAddress() != null) {
if (getAddress().getFeatureName() == null &&
getAddress().getAddressLine(0) != null) {
new UpdatePoint().execute(String.valueOf(coins),
String.valueOf(steps),
String.valueOf(originLocation.getLatitude()),
String.valueOf(originLocation.getLongitude()),
getAddress().getFeatureName(), "not titled");
} else if (getAddress().getFeatureName() != null &&
getAddress().getAddressLine(0) == null) {
new UpdatePoint().execute(String.valueOf(coins),
String.valueOf(steps),
String.valueOf(originLocation.getLatitude()),
String.valueOf(originLocation.getLongitude()),
"not titled", getAddress().getAddressLine(0));
} else {
new UpdatePoint().execute(String.valueOf(coins), String.valueOf(steps),
String.valueOf(originLocation.getLatitude()), String.valueOf(originLocation.getLongitude()),
getAddress().getFeatureName(), getAddress().getAddressLine(0));
}
} else {
new UpdatePoint().execute(String.valueOf(coins), String.valueOf(steps),
String.valueOf(originLocation.getLatitude()), String.valueOf(originLocation.getLongitude()),
"not titled", "not titled");
}
So, any Ideas about
how to use an asyncTask in a service with different process?
or
any other way in order to update the server from a service with different process?
any helps would be appreciated a lot!
Thanks.

1
why don't you look at work manager if battery saving is needed. you can then schedule your sync jobs . you could use a foreground service and a normal handler thread or thread. i don't think you need a service in a different process
– Raghunandan
Jan 1 at 11:30
1
Just read and apply if you found it useful developer.android.com/training/sync-adapters/…
– Chandrakant Dvivedi
Jan 1 at 11:34
@Raghunandan thank you so much I'll take a look at it.
– Sina
Jan 1 at 14:16
@ChandrakantDvivedi Thanks a lot! I'll check it out asap.
– Sina
Jan 1 at 14:16
add a comment |
I'm using a Service in different process of my app using android:process=":MyService"
and I recognized that my AsyncTasks in MyService class doesn't work and execute, so how can I sync my datas with my Server in MyService class?
I just want to update my Server from this class cause it's a ForegroundService that should be active most of the times. I believe that defining MyService class as a separate process helps my app's battery usage. I've already defined an inner class and used it inside MyService class but it doesn't work at all, I also tried to use another custom asyncTask class Object in MyService class but it doesn't work either
here's an example of my code in MyService class:
static class UpdatePoint extends AsyncTask<String,String,String>{
@Override
protected String doInBackground(String... strings) {
String userId = user.get(SessionManager.getKeyId()).toString();
String coin = strings[1];
String step = strings[2];
String log_lat = strings[3];
String log_lng = strings[4];
String log_zone = strings[5];
String log_address = strings[6];
//Log.d("updatePoint","coin:"+coin+", step:"+step);
try {
String update_point_url = "http://mohregroup.ir/db-mapapa/updatePoint.php";
URL url = new URL(update_point_url);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setConnectTimeout(5*1000);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
OutputStream outputStream = httpURLConnection.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
String data = URLEncoder.encode("userId", "UTF-8") + "=" + URLEncoder.encode(userId, "UTF-8")
+ "&" + URLEncoder.encode("coin", "UTF-8") + "=" + URLEncoder.encode(coin, "UTF-8")
+ "&" + URLEncoder.encode("step", "UTF-8") + "=" + URLEncoder.encode(step, "UTF-8")
+ "&" + URLEncoder.encode("log_lat", "UTF-8") + "=" + URLEncoder.encode(log_lat, "UTF-8")
+ "&" + URLEncoder.encode("log_lng", "UTF-8") + "=" + URLEncoder.encode(log_lng, "UTF-8")
+ "&" + URLEncoder.encode("log_zone", "UTF-8") + "=" + URLEncoder.encode(log_zone, "UTF-8")
+ "&" + URLEncoder.encode("log_address", "UTF-8") + "=" + URLEncoder.encode(log_address, "UTF-8");
bufferedWriter.write(data);
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
InputStream inputStream = httpURLConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "iso-8859-1"));
StringBuilder response = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
response.append(line);
}
//Log.d("updatePoints response:", response.toString().trim());
bufferedReader.close();
inputStream.close();
httpURLConnection.disconnect();
Timber.d("done Successfully!");
return response.toString();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
and using it inside another method of MyService class :
if (getAddress() != null) {
if (getAddress().getFeatureName() == null &&
getAddress().getAddressLine(0) != null) {
new UpdatePoint().execute(String.valueOf(coins),
String.valueOf(steps),
String.valueOf(originLocation.getLatitude()),
String.valueOf(originLocation.getLongitude()),
getAddress().getFeatureName(), "not titled");
} else if (getAddress().getFeatureName() != null &&
getAddress().getAddressLine(0) == null) {
new UpdatePoint().execute(String.valueOf(coins),
String.valueOf(steps),
String.valueOf(originLocation.getLatitude()),
String.valueOf(originLocation.getLongitude()),
"not titled", getAddress().getAddressLine(0));
} else {
new UpdatePoint().execute(String.valueOf(coins), String.valueOf(steps),
String.valueOf(originLocation.getLatitude()), String.valueOf(originLocation.getLongitude()),
getAddress().getFeatureName(), getAddress().getAddressLine(0));
}
} else {
new UpdatePoint().execute(String.valueOf(coins), String.valueOf(steps),
String.valueOf(originLocation.getLatitude()), String.valueOf(originLocation.getLongitude()),
"not titled", "not titled");
}
So, any Ideas about
how to use an asyncTask in a service with different process?
or
any other way in order to update the server from a service with different process?
any helps would be appreciated a lot!
Thanks.

I'm using a Service in different process of my app using android:process=":MyService"
and I recognized that my AsyncTasks in MyService class doesn't work and execute, so how can I sync my datas with my Server in MyService class?
I just want to update my Server from this class cause it's a ForegroundService that should be active most of the times. I believe that defining MyService class as a separate process helps my app's battery usage. I've already defined an inner class and used it inside MyService class but it doesn't work at all, I also tried to use another custom asyncTask class Object in MyService class but it doesn't work either
here's an example of my code in MyService class:
static class UpdatePoint extends AsyncTask<String,String,String>{
@Override
protected String doInBackground(String... strings) {
String userId = user.get(SessionManager.getKeyId()).toString();
String coin = strings[1];
String step = strings[2];
String log_lat = strings[3];
String log_lng = strings[4];
String log_zone = strings[5];
String log_address = strings[6];
//Log.d("updatePoint","coin:"+coin+", step:"+step);
try {
String update_point_url = "http://mohregroup.ir/db-mapapa/updatePoint.php";
URL url = new URL(update_point_url);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setConnectTimeout(5*1000);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
OutputStream outputStream = httpURLConnection.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
String data = URLEncoder.encode("userId", "UTF-8") + "=" + URLEncoder.encode(userId, "UTF-8")
+ "&" + URLEncoder.encode("coin", "UTF-8") + "=" + URLEncoder.encode(coin, "UTF-8")
+ "&" + URLEncoder.encode("step", "UTF-8") + "=" + URLEncoder.encode(step, "UTF-8")
+ "&" + URLEncoder.encode("log_lat", "UTF-8") + "=" + URLEncoder.encode(log_lat, "UTF-8")
+ "&" + URLEncoder.encode("log_lng", "UTF-8") + "=" + URLEncoder.encode(log_lng, "UTF-8")
+ "&" + URLEncoder.encode("log_zone", "UTF-8") + "=" + URLEncoder.encode(log_zone, "UTF-8")
+ "&" + URLEncoder.encode("log_address", "UTF-8") + "=" + URLEncoder.encode(log_address, "UTF-8");
bufferedWriter.write(data);
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
InputStream inputStream = httpURLConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "iso-8859-1"));
StringBuilder response = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
response.append(line);
}
//Log.d("updatePoints response:", response.toString().trim());
bufferedReader.close();
inputStream.close();
httpURLConnection.disconnect();
Timber.d("done Successfully!");
return response.toString();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
and using it inside another method of MyService class :
if (getAddress() != null) {
if (getAddress().getFeatureName() == null &&
getAddress().getAddressLine(0) != null) {
new UpdatePoint().execute(String.valueOf(coins),
String.valueOf(steps),
String.valueOf(originLocation.getLatitude()),
String.valueOf(originLocation.getLongitude()),
getAddress().getFeatureName(), "not titled");
} else if (getAddress().getFeatureName() != null &&
getAddress().getAddressLine(0) == null) {
new UpdatePoint().execute(String.valueOf(coins),
String.valueOf(steps),
String.valueOf(originLocation.getLatitude()),
String.valueOf(originLocation.getLongitude()),
"not titled", getAddress().getAddressLine(0));
} else {
new UpdatePoint().execute(String.valueOf(coins), String.valueOf(steps),
String.valueOf(originLocation.getLatitude()), String.valueOf(originLocation.getLongitude()),
getAddress().getFeatureName(), getAddress().getAddressLine(0));
}
} else {
new UpdatePoint().execute(String.valueOf(coins), String.valueOf(steps),
String.valueOf(originLocation.getLatitude()), String.valueOf(originLocation.getLongitude()),
"not titled", "not titled");
}
So, any Ideas about
how to use an asyncTask in a service with different process?
or
any other way in order to update the server from a service with different process?
any helps would be appreciated a lot!
Thanks.


edited Jan 1 at 13:16


Fantômas
32.7k156390
32.7k156390
asked Jan 1 at 11:25


SinaSina
337
337
1
why don't you look at work manager if battery saving is needed. you can then schedule your sync jobs . you could use a foreground service and a normal handler thread or thread. i don't think you need a service in a different process
– Raghunandan
Jan 1 at 11:30
1
Just read and apply if you found it useful developer.android.com/training/sync-adapters/…
– Chandrakant Dvivedi
Jan 1 at 11:34
@Raghunandan thank you so much I'll take a look at it.
– Sina
Jan 1 at 14:16
@ChandrakantDvivedi Thanks a lot! I'll check it out asap.
– Sina
Jan 1 at 14:16
add a comment |
1
why don't you look at work manager if battery saving is needed. you can then schedule your sync jobs . you could use a foreground service and a normal handler thread or thread. i don't think you need a service in a different process
– Raghunandan
Jan 1 at 11:30
1
Just read and apply if you found it useful developer.android.com/training/sync-adapters/…
– Chandrakant Dvivedi
Jan 1 at 11:34
@Raghunandan thank you so much I'll take a look at it.
– Sina
Jan 1 at 14:16
@ChandrakantDvivedi Thanks a lot! I'll check it out asap.
– Sina
Jan 1 at 14:16
1
1
why don't you look at work manager if battery saving is needed. you can then schedule your sync jobs . you could use a foreground service and a normal handler thread or thread. i don't think you need a service in a different process
– Raghunandan
Jan 1 at 11:30
why don't you look at work manager if battery saving is needed. you can then schedule your sync jobs . you could use a foreground service and a normal handler thread or thread. i don't think you need a service in a different process
– Raghunandan
Jan 1 at 11:30
1
1
Just read and apply if you found it useful developer.android.com/training/sync-adapters/…
– Chandrakant Dvivedi
Jan 1 at 11:34
Just read and apply if you found it useful developer.android.com/training/sync-adapters/…
– Chandrakant Dvivedi
Jan 1 at 11:34
@Raghunandan thank you so much I'll take a look at it.
– Sina
Jan 1 at 14:16
@Raghunandan thank you so much I'll take a look at it.
– Sina
Jan 1 at 14:16
@ChandrakantDvivedi Thanks a lot! I'll check it out asap.
– Sina
Jan 1 at 14:16
@ChandrakantDvivedi Thanks a lot! I'll check it out asap.
– Sina
Jan 1 at 14:16
add a comment |
1 Answer
1
active
oldest
votes
One way could be using timer and when timer is finished you can call asynctask and reset the timer again.
it could be, but I'm not sure it's suitable for my purposes. i need to sync my app to the server as soon as possible.
– Sina
Jan 1 at 14:18
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53995038%2fhow-to-use-asynctask-in-a-different-process%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
One way could be using timer and when timer is finished you can call asynctask and reset the timer again.
it could be, but I'm not sure it's suitable for my purposes. i need to sync my app to the server as soon as possible.
– Sina
Jan 1 at 14:18
add a comment |
One way could be using timer and when timer is finished you can call asynctask and reset the timer again.
it could be, but I'm not sure it's suitable for my purposes. i need to sync my app to the server as soon as possible.
– Sina
Jan 1 at 14:18
add a comment |
One way could be using timer and when timer is finished you can call asynctask and reset the timer again.
One way could be using timer and when timer is finished you can call asynctask and reset the timer again.
answered Jan 1 at 11:31
Viraj SViraj S
27418
27418
it could be, but I'm not sure it's suitable for my purposes. i need to sync my app to the server as soon as possible.
– Sina
Jan 1 at 14:18
add a comment |
it could be, but I'm not sure it's suitable for my purposes. i need to sync my app to the server as soon as possible.
– Sina
Jan 1 at 14:18
it could be, but I'm not sure it's suitable for my purposes. i need to sync my app to the server as soon as possible.
– Sina
Jan 1 at 14:18
it could be, but I'm not sure it's suitable for my purposes. i need to sync my app to the server as soon as possible.
– Sina
Jan 1 at 14:18
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53995038%2fhow-to-use-asynctask-in-a-different-process%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
why don't you look at work manager if battery saving is needed. you can then schedule your sync jobs . you could use a foreground service and a normal handler thread or thread. i don't think you need a service in a different process
– Raghunandan
Jan 1 at 11:30
1
Just read and apply if you found it useful developer.android.com/training/sync-adapters/…
– Chandrakant Dvivedi
Jan 1 at 11:34
@Raghunandan thank you so much I'll take a look at it.
– Sina
Jan 1 at 14:16
@ChandrakantDvivedi Thanks a lot! I'll check it out asap.
– Sina
Jan 1 at 14:16