Services - Thread In Background That Makes Request To An External Api

I'm developing an android application. Actually, i have a thread in background that makes request to an external api in order to get data when the users clicks in different parts of the app. My doubt is if this "thread" would be better if i implemented it as a service instead of a runnable class.

View Full Post With 3 Replies

Related Forum Messages:

Please Follow Index to Quick Jump to the Message.

Cannot Disable " Data Background Services " After Upgrade To Ics - Samsung Galaxy S2

Since upgrading to ics (ice cream sandwich) with my galaxy s2, one of the changes is you can no longer disable "data background services". When i bought my phone a couple of months ago i was told in the o2 shop to disable data background services to enhance the battery life. I did this and the battery lasted really well as i only enabled the service when i needed to. This facility has now gone and i am finding my battery life really quite poor.

I don't use the mobile network for internet as have wifi at home and work so my phone is connected to that. I notice it must be doing things in the background as i get alerts for facebook, twitter etc so i presume it is working hard in the background and that is what using the battery. Does anyone have any suggestions as to how i can improve the battery life. It is really annoying that this has gone with the upgrade as it certainly made a big difference.

Posted On: 2012-04-19 . View Related Posts . . View 20 Replies .

Gw620 Makes Data Connection

Gw620 makes data connection, edge or 3g, by itself. I restored factory settings, all sync profiles are gone, but still it makes connection. I made an empty profile for data, so it can not connect. Where can i see, what program wants to connect?

Posted On: 2010-05-14 . View Related Posts . . View 1 Replies .

4 Threads As Services

I want to implement 4 threads as services in android. How di i do that. Can anyone suggest a good example for the same. ?

Posted On: Aug 2 at 15:02 . View Related Posts . . View 1 Replies .

Remoteexceptions And Services

I've written a service and an activity for the android os.

My service is running in it's own process, so all the communication between my activities and the service happens via ipc. I use the standard android . Aidl mechanism for this.

So far everything works fine. However, the aidl generates all method stubs using "throws remoteexception" so i have to handle them.

I did a quick grep on the entire android source-code and only found three cases where this exception is ever thrown. These are in a different service that i don't connect with.

I checked the c-sources as well because in theory remoteexceptions can be generated using the jni interface. Nothing turned up.

I have the impression that everyone just handles them like this:


This is not solid code, and i don't want something like this in my code-base.

Besides that: i tried to throw a remoteexception via ipc myself and all i got was a stack-trace and a system log message that tells me that exceptions aren't supported yet. My application never saw the exception and the services that threw the exception ended up in a very strange state (halfway working) :-(

The questions are:

Do these exceptions ever get thrown?
Has anyone ever seen such a try-catch block catching a remoteexception?
Could it be that they don't exist and that we are just forced to deal with them because the "throws remoteexception" is dead code or a left-over inside the aidl compiler?

Disclamer: i haven't read the entire source-code. I used grep to find the occurrences of remoteexception, so i may have missed some due to different whitespace usage.

Posted On: Jul 1 at 9:07 . View Related Posts . . View 1 Replies .

How To Use Sqlite From Services

It's sad how hard it is to find a simple line of code that does this "in my opinion".

Anyhow, the problem is i have a program with activities and services "i am new to services". I can access my sqlite database from activities using thedb class:


And then i can just call the methods, e.g.

Myactivity class:


Thedb class (method called from myactivity):


All i want to be able to do is call thedb's methods from my service like i do from myactivity.

Do i make a new constructor? Do i change the way i instantiate it?

Posted On: Nov 22 at 3:59 . View Related Posts . . View 1 Replies .

Htc Desire - Want App That Makes Pizza

How about an app that makes pizza?

Seems like my desire can do everything else, and i'm hungry.

Posted On: 10-19-2010, 03:32 PM . View Related Posts . . View 2 Replies .

What Makes It Impossible To Exchange Applications Between Phones

I've got some questions about a possible android weak point:

1. What makes it impossible to exchange applications between android phones? Can't they be cracked? If so, what's the use of android market?
And don't tell me that this is illegal :-).

2. Would an android based p2p application be accepted in the android market?

Posted On: 10-25-2008, 11:31 AM . View Related Posts . . View 10 Replies .

Services And Activities Lifecycles

I have some questions about the android service and activity lifecycles. I have written an application that uses gps location and stores them. It must monitor the gps location updates constantly to work properly.

Right now, it's all in one activity. So when you close the activity, you loose everything and can't continue monitor location updates. This is why i wanted to make a background service for the monitoring part. And i've been reading the android developer guide and the reference, but still can't fully understand the activity-service-process-lifecycle thing.

Consider this: you start the application. It gets a gps fix and now you can start monitoring the location updates and save them. When you do so, it should start a service that receives gps location updates. So now you have an activity and a service running in the same process. Ok. But what happens if you push the hardware back-button on your phone? Will only the activity be killed with the process still running your service? Or will it kill both, the activity and the service and thus also the process? Is there some way to ensure the service keeps running in the same process after the activity is killed? But a way not so complicated as the whole aidl thing for remote processes?

Creating a service in a new process seems unnecessary to me, because no other application should use my service, i just need the monitoring part to keep running while the (gui) activity is dead. I wanted to make something like the local service example on the developer site, but i must be sure the service keeps running after the activity is killed.

Posted On: Aug 25 at 20:26 . View Related Posts . . View 1 Replies .

Why Changing Color Of Default Button Makes It Look Rectangle

Why changing color of default button makes it look rectangle shape ? I do not want to use custom background images for this.

I want to do this programmatically for few conditions on which i change the colors of many small buttons on screen.

It seems there is no workaround by reading this

Posted On: May 5 at 4:49 . View Related Posts . . View 3 Replies .

Samsung Fascinate - Keyboard Button Just Makes Symbol / Why Is This

Has anyone else noticed that the "-" button just makes the "_" symbol? It's annoying me that i can't hyphenate a name. Am i missing something?

Posted On: 10-25-2010, 07:13 PM . View Related Posts . . View 4 Replies .

How To Ping External Ip From Java

I am developing a ping application for android 2. 2.

I try my code and works ok but only in local ips, thats my problem i want to do ping to external servers too.

Here is my code:


Posted On: Oct 11 at 10:30 . View Related Posts . . View 1 Replies .

How To Use External Jars In Project

I have created an android project and added an external jar (hessian-4. 0. 1. Jar) to my project. I then add the jar to the buildpath and check it of in order and export.

Order and export is ignored it seams, and all classes from the external jar is missing in runtime.

Is there a trick to properly include the needed classes from an external jar when building an android application using the eclipse plug-in. I do not want to use ant of maven.

Posted On: Aug 26 09 at 13:45 . View Related Posts . . View 4 Replies .

Create An Application With Ws-* Services Connections

How to create an android application with ws-* services connections? Where to get information for beginners - it should contain video tutorials and explanation what types of bindings are not supported.

Posted On: Dec 19 09 at 21:36 . View Related Posts . . View 3 Replies .

Amazon Web Services - Aws

I have a simple app that uses aws to lookup and fetch product information. This works fine on the desktop, using the sun jre.

However, in trying to port this to android i am hitting all sorts of problems, including first missing classes in javax.xml (specifically javax.xml. Transform. Stream. Streamsource), which i can work around, but then external jars that appear to prevent the app from being built. For example:

Warning: ignoring innerclasses attribute for an anonymous inner class that doesn't come with an associated enclosingmethod attribute. (This class was probably produced by a broken compiler. )

And then:

[2009-02-22 13:00:21 - dex loader] unable to execute dex: null conversion to dalvik format failed: unable to execute dex: null

Should i wait until there is an android version of aws available, or is this something that i can fix myself?

Posted On: (1 user) Feb 22 2009 . View Related Posts . . View 19 Replies .

Context-aware Web Services

I am starting an msc thesis and i investigating in the field of context-aware mashups. Do you guys know if there are any standard which have already been set on the way the context or point of interests are sent to the server? Like location, social information, language and other information about the mobile being sent in a particular format like a dom or tree like structure or maybe xml.

Posted On: Nov 1 at 17:05 . View Related Posts . . View 1 Replies .

Best Practise To Deal With Killed Services

I often see that services are killed and then "restarted". I can force this behavior when opening many applications. "Low memory" or "outofmemory" are not problems per se, are they? This is just the normal behavior due to android not closing applications, but killing the least important processes when more memory is needed, right? The terminology "crashed service" at least sounds very serious.

Is there any guaranteed call back available to clean up first before being killed? I set an ongoing notification when the service starts and clear it when it finishes. Unfortunately the notification isn't cleared when the service is just killed and it hangs around until the service is the next time triggered. Why are those services restarted? Are they always restarted? And what exactly happens when a service is restarted? Should i just clear the notification in the service's oncreate() method. To avoid the overhead of two processes i just use a single process for my ui and the service. Should i rework my code (stop sharing static variables) and use two separate processes?

Posted On: Jul 13 2009 . View Related Posts . . View 4 Replies .

Htc Desire - Phone Creak A Little When It Makes Vibration / Fix It

Ive noticed that when i have vibrate feedback on my phone sometimes makes like a slight creaking noise when it makes the vibration. Anyone else?

Posted On: 06-15-2010, 05:29 PM . View Related Posts . . View 7 Replies .

External Storage File Creation

The following is the code that am using to create a small text file on the external storage. But the problem is its saying can't read nd can't write.

Note : bollo() is a method with has a toast to display on the screen dont confuse with that method.


Posted On: Oct 11 . View Related Posts . . View 10 Replies .

Google Maps External Library

A not so small part of the android devices are not including the google maps external library. My first question is: how can a vendor/manufacturer include it on his devices, is there a process of obtaining a license for the use of the library or there are some conditions to apply for such a license?

My second one: is there a nicer way to address this issue other than have 2 builds/apks, one that uses the library, with added in the manifest, and the other one, without the use of the library?

Posted On: Oct 20 . View Related Posts . . View 2 Replies .

Sockets - Threads And Services - How To Make Them Work Together

I am facing a probleme with threads and sockets i cant figure it out, if someone can help me please i would really appreciate.

There are the facts :

I have a service class networkservice, inside this class i have a socket attribute.
I would like it be at the state of connected for the whole lifecycle of the service.

To connect the socket i do it in a thread, so if the server has to timeout, it would not block my ui thread.

Problem is, into the thread where i connect my socket everything is fine, it is connected and i can talk to my server, once this thread is over and i try to reuse the socket, in another thread, i have the error message socket is not connected.

Questions are :
- Is the socket automatically disconnected at the end of the thread?
- Is their anyway we can pass back a value from a called thread to the caller ?

Here is my code:


Posted On: May 4 at 13:24 . View Related Posts . . View 1 Replies .

Motorola - Turn Off Motoblur Services On Backflip?

I am having problems with phone locking when the wifi is connected and it's trying to log on to blur services. Is there a way to turn off motoblur services on the backflip? I don't use them anyway.

Posted On: Nov 4, 2010 10:32 AM . View Related Posts . . View 6 Replies .

Stop Google Services From Running - Lg Esteem

Is there a way to stop this google services from running on my applications ? Im kind of a ram whore and i don't like things running when i don't want them to. So is there anyway to keep it from running or must it run or is it bad to take off in the first place ?

Posted On: 2012-04-17 . View Related Posts . . View 8 Replies .

Motorola Droid - Car Dock Makes A Hole In Phone / Should I Exchange It

When holding your droid away from you with the battery and camera facing you 申 the camera to the top left 申 is there a small notch at the very top toward the right side of the headphone jack but on the very back phone wide long rectangle piece of almost rubber feeling material? I haven申t noticed this before but now i see it 申 only thing that i could think of is that my car dock made this if it wasn't already there 申 is this part of the original design or no? Should i exchange?

Posted On: 11-17-2009, 01:24 PM . View Related Posts . . View 10 Replies .

Issue: Tethering Makes Data Connection Icon Disappears On Galaxy S2

Everytime i set up my phone for wifi tethering i seem to have a problem. The main thing i notice is my data connection icon disappears i.e 3g, h, h+ with the up/down arrow flashing indication data transfer. However, when i switch off the tethering the icon reappears. The same thing happens when i even try usb tethering. The last time it has worked was before i updated it to 2. 3. 5 from 2. 3. 3. Can anyone advise, thanks in advance.

Posted On: February 26th 2012 . View Related Posts . . View 0 Replies .

Reusing Code - Multiple External Namespaces

What's the proper way to share code and layouts between android projects? (I work with eclipse)

Explanation and my problem:

I'm working in multiple projects that share the same base (an activity-less android project). This project have some graphical classes with its layouts in xml and require both to work properly. Normally i copy this code and change the r. Id definitions on the project to match the current 'sub-project' but, obviously, this is not the proper way of reusing code.

Now i have two eclipse projects, one of them has the 'base' code and the other is the current application. I defined a dependency but it seems that i can refer to the classes from java, but i can't in this other project's layouts. I tried declaring its namespace in xml files, but it doesn't work.

I can't believe the way is copy+paste and search+replace.

Posted On: Jun 14 2009 . View Related Posts . . View 2 Replies .

Possible To Create Droid Database Without External Tools

I have been searching for this for the past few days and every tutorial i see needs for me to use an external package. Is there anything built into the android sdk that would allow me to create a database? I thought i saw something on it a long time ago, but i can't find anything to back that foggy memory up.

Posted On: Oct 5 at 6:59 . View Related Posts . . View 1 Replies .

Close Alertdialog Builder From External Button

Well it's all in the subject :) do u have any ideas about how to dismiss a builder from an external button. I did mybuilder. Create(). Dismiss() inside the onclicklistener of the button. But it doesn't work.

Posted On: May 27 . View Related Posts . . View 3 Replies .

Htc Incredible No Default External Storage

The htc incredible is now available for pre order at verizon. Engadget has already done a review. They mention that there is a storage issue with a lot of apps because it does not come with an external sd card by default. It does have a lot of separate internal storage, but apps cannot use it. Does anyone have more info about this from a developer's point of view. What path will environment. Getexternalstoragedirectory() return and what is the correct way to get the path of the internal storage?

Posted On: Apr 19 . View Related Posts . . View 22 Replies .

Vehicle Dock - Using External Speakers While In A Call

When my phone is in the vehicle dock the sound is pumped out of the car speakers perfectly until i take a call, at which point it reverts to the phone speaker. Whilst the mi've is able to pick up my voice from the cradle, i can't hear the speaker. How do you get it to continue to use the external speakers whilst in a call? Yes, use external speaker whilst docked is selected.

Posted On: 2011-30-01 . View Related Posts . . View 11 Replies .