Android :: How To Send Back Data From Thread To Service?

Aug 31, 2010

I have a service from which a start a new thread. This new thread will communicate with a TCP server using socket. What is the best way to send the data received from TCP server back to the service? Handlers or something else?

Android :: How to Send Back Data from Thread to Service?


Android :: Protect Shared Data Between Service And Thread

Jun 23, 2010

I'm doing an application that requires that certain thread access data that's shared among it and another service.How can I protect these shared data form accessing in the same time is there anything in android for that or android has nothing to do with this as Java API's will do the job.

View 7 Replies View Related

Android :: Send Data Using CSD / Data Channel Of GSM Service?

Jul 28, 2010

I wanna develop an app that uses CSD or Data channel of GSM Service to send data. Can anyone help me out with it?

View 1 Replies View Related

Android :: Google Marketplace ID Of Purchaser Of App To Send It To Back-end Service Database

Oct 22, 2010

Is there a way I can get the Google Marketplace ID of the purchaser of my app? I mean from within the app at runtime. I want to send it to my back-end service database to help detect pirates.

View 6 Replies View Related

Android :: Intents In Queue - Send Data Via Web Service

Sep 29, 2010

Is it possible, with an IntentService, to send another intent to the IntentService from within the IntentService? For example, say my IntentService is processing an Intent which has it write a bunch of data to the database. During this time, several other Intents to write other data may [or may not] have been queued up in the IntentService. Suppose, after processing that Intent by writing the data to the application's database, I want to queue up another Intent to send that data via web service to "the cloud." Perhaps I want to queue this processing in another Intent because sending to the cloud is secondary. Is it possible? Would it cause any problems if the Intent being processed is the only Intent in the queue at the time the IntentService is trying to queue another Intent?

View 2 Replies View Related

Android :: Way To Send Data From Service To Widget On Phone?

Apr 28, 2010

I am writing a widget on Android 1.6 that shows the minutes that a person has used on the current month.
The way I have it setup is by having a service that listens to the state of the phone and when the phone is picked up, it starts the timer and when the person hangs up, ends a timer. I would like to send this variable(long duration) over to my appWidgetProvider so I could update the edit text on it.

View 1 Replies View Related

Android :: Getting Data Back From Service?

Jan 12, 2010

I have created an activity that calls a service. This service receive an XML feed and parse the info. Each time I get the info for a new station i want to send the details (Name,Id,Location all as string) back to my main activity so it can load it inside a list view. When I run my code inside the main activity it works. When I move it to a service I cant send the data back. This is what I have tried. After getting the current station info from I do this: submit Station(namer, loc, ids, dis, types); then: private void submit Station(String names, String loca, String idss, String diss, String typess){Intent intent = new Intent(NEW_STATION_LISTING); intent.putExtra("Station Name",names); intent.putExtra("Sid", loca); intent.putExtra("StationLoc", idss); intent.putExtra("Distance", diss); intent.putExtra("Types", typess);send Broadcast(intent);}

View 3 Replies View Related

Android :: Sending Data Back And Forth Between Activity And Service Locally?

Aug 13, 2010

I am a bit new to Android. What I need to do is send data back and forth between an activity and a service locally. The information sent is sensitive and must not be able to be picked up by other apps. This excludes using broadcast and the onBind() function if I understand things correctly? So the activity needs to send some string parameters to the service. Also it somehow needs to tell the service which activity started it so the service can reply to the correct class since many different activities will use this service.

Once the service has fetched the information via a http request it is suppose to send that data (just a long string which will later be parsed) back to the activity that started it. How do I go about doing this? Using static variables/functions is not an option since again many actives will be using this service. Sure it would be possible to use a static array to hold the classes but that just seems ugly. It's only possible to send simple variables (not objects) via the intent? There must be a better way to do this.

View 1 Replies View Related

Android :: Activity Which Downloads Data In Background With Service - Doesn't Get Destroyed On Hitting Back Button

Nov 9, 2010

I need to develop an application with downloads the data at the background and update about the progress in the front.

I guess this can be achieved using services and activity and passing data in between the. But, what I need to do is even if I hit back button and then start the activity again. It should check if the service is running or not. If service is not running it should start one else it should display the data from running service.

Something like music player where music is played by a service at a background and activity displays the information. Even on browsing through other activities of the application or hitting back, state of the music player is maintained.

View 1 Replies View Related

Android :: Send Data (String) From Activity To Service In Android?

Feb 15, 2010

Usually, I putExtra inside an Intent to transfer stuff between Activities. But it seems like I can't do this with a Service? Bundle extras = getIntent().getExtras(); That doesn't work for a android Service. How do I send a string from an Activity to a Service then?

View 1 Replies View Related

Android :: Two Threads And 1 Service / Or Service Per Thread?

Nov 20, 2010

what I'm trying to do here is implement something like a peer-to-peer client. Being that, it will start a client thread and a server thread.I know Services themselves run in the main GUI thread, so I'll have to start a couple of independent threads (or Asynctasks?) for each server and client. The only thing I'm not so sure about is if I'll better have 1 Service starting 2 threads, or maybe 2 services, each one of them starting their own thread.

View 2 Replies View Related

Android :: Service Within Thread?

Jan 18, 2010

I am new to Java and Android.I would like to retrieve remote data and display it within my activity. To prevent tying up to UI, I understand that I can do this in another thread. (I thought I could just-as-well fetch this remote data from within a service, but that appears to tie up the UI thread also). So now I'm beginning to think I need to either run the logic from a new thread within a service, or run a service within a new thread. But which? I have found many examples online of running new threads or services, but I have yet to find an example of both at the same time.

View 7 Replies View Related

Android :: Using Thread In Activity Or In Service?

Jun 12, 2010

In Virgil Dobjanschi's talk, "Developing Android REST client applications" (link here), he said a few things that took me by surprise. Including:
Don't run http queries in threads spawned by your activities. Instead, communicate with a service to do them, and store the information in a ContentProvider.
Use a ContentObserver to be notified of changes.
Always perform long running tasks in a Service, never in your Activity.
Stop your Service when you're done with it.

I understand that he was talking about a REST API, but I'm trying to make it fit with some other ideas I've had for apps. One of APIs I've been using uses long-polling for their chat interface. There is a loop http queries, most of which will time out. This means that, as long as the app hasn't been killed by the OS, or the user hasn't specifically turned off the chat feature, I'll never be done with the Service, and it will stay open forever. This seems less than optimal.

Long question short:
For a chat application that uses long polling to simulate push and immediate response, is it still best practice to use a Service to perform the HTTP queries, and store the information in a ContentProvider?

View 1 Replies View Related

Android :: What Is Difference Between Thread And Service?

May 26, 2009

I want to download some data from internet.It should not block main UI thread. I know both thread and service can handle the work. What is the difference between them?

View 4 Replies View Related

Android :: Should I Use Service Or Local Thread ?

Oct 6, 2010

I have an application which requires networking service. I took on LWUIT4IO and adjusted it to my needs so now i have a network queue that can run one or more network threads.Now, my application is based on single root activity that spawns other child activities as needed (it's a reservation center for vacations, car rental etc.. each in it's own activity). The network is common to all and should be used by all activities. the network thread requires, basically, a callback to notify it's finished and return the result (input stream or byte array) .At first i thought that i should use a service instead of a singleton that will be started in the root activity(the service will also be started in the root activity), however working with a local service is problematic for me: 1. no callbacks which makes me use intents to encapsulate the request esponse in intents time consuming, also since there is not single point of listening (i have to use BroadcastReceivers)i have to add a calling class name or some other identifier so the sender of the request will know it's for him, i think this is also a waste of time and resources since i need only one listener.

i think i CAN use callbacks if i use Binder object to return local instance of my Service and then use the queuing method directly, this is problematic for me as acquiring Binder object is asynchronous and i need it 'on the spot' 3. I thought of using a static instance of the service and null it in onDestroy of the service, but if i use that way, i'm not so sure i need a service... 4. i saw a small answer in stackoverflow about inheriting application and putting whatever member you need there so when you use getApplication you get this instance and then you can retrieve whatever you want, is this even advisable ?

View 5 Replies View Related

Android :: Service Thread Priority

Dec 16, 2009

I have two apps that use a service to upload and download files and data. I've noticed that when the service gets very busy, it can cause the UI to block, up to the point that Android shows a "force quit/ wait" popup. In order to avoid that, I run tasks in a service at a lower priority. This way, the service will never cause the UI to hickup. Also, the service stops if the app hasn't been used for a certain number of minutes. I don't want to keep resources if the user isn't using my app.I have found that some of my users run apps that run services permanently at normal priority. Such a service starts at phone switch on, and keeps running indefinitely, downloading vast amounts of data. My policy of being nice to other apps doesn't pay off: these agressive third party services push my service away so it never gets anything done. As one of my users told me, my app has hickups, until he kills the service of this app X, after which my app runs smoothly, snappy, and fast.

My question is, should I be nice to other apps and to the UI in my own app, or should I just run a service and agressively take all resources I need - or don't need? This is one issue where Android is different from iPhone. We can run services, but by doing so, we can cause damage to other peoples apps. Of course, my "question" doesn't require an answer. I'm just curious after what other people think, what your experience here is.

View 5 Replies View Related

Android :: How To Start A New Thread In Service?

Nov 14, 2010

I am developing an Android app and I am doing some heavy work (bringing data from an online web page and parsing it to store in database) in a service. Currently, it is taking about 20+ mins and for this time my UI is stuck. I was thinking of using a thread in service so my UI doesn't get stuck but it is giving error.

View 1 Replies View Related

Android :: Possible To Send An Event From A Thread To An Activity?

Jan 28, 2010

If I want to send an event, e.g. OnClick, to an activity from a thread? The expected work flow is below:public class HelloAndroid extends Activity {public void onCreate(Bundle savedInstanceState)Code...

View 4 Replies View Related

Android :: How To Send Current Thread To Sleep

Oct 16, 2010

Code...

This code don't work

View 1 Replies View Related

Android :: Broadcast Receiver / Service & Thread

Jun 23, 2010

I am starting to develop a new app and I am a bit confused about the structure I need to give it.I need to react to broadcast intents, so I placed a broadcast received in the manifest. Every single intent produces an action to be performed. Now the first question: should I start a service (maybe with non_sticky option?) or should I start a thread (or an async task) directly from the broadcast receiver? If I start a service, should I do all the stuff in its body, or should it start a thread. I should do the heavy job in a thread if there are time consuming operations, but what if the gui of my application is just an activity with the options and a button to start the service. What is the point in keeping the main thread busy? Do I risk to be killed for not being responsive? I read here and there that I can update the gui from a background thread. Can I do that even if it is started from a service? The AsyncTask's onProgressUpdate is said to run in the application main thread, but if the application is made of different activities, who tells me which activity is the user looking at while the thread is doing all its long work? The user could change activity in the meanwhile and then the update would be unuseful.I know it's (quite) a lot of questions, but I need to get some clarifications before taking the wrong path.

View 5 Replies View Related

Android :: Intent Service Not Actually Spawning New Thread

Sep 16, 2010

My IntentService is blocking my UI thread and I wanted to find out why. So I turned on profiling in the onStartCommand method of the IntentService and turned it off at the end of the onStartMethod. The working being done in between is web access with the Apache HTTP client.According to the profiler, the onStartCommand method of the IntentService is running on the main thread, not in a worker thread. Any idea what could cause this behavior?

View 3 Replies View Related

Android :: Starting Service In Separate Thread

Jul 27, 2009

i have a little frontend showing a list of items that it will retrieve from a service. I want that service to be started in a separate thread.so the UI is still responding to user interaction while waiting for that service to call a callback method. What is the best way to start the service in a detached thread?

View 6 Replies View Related

Android :: Whether To Use Service Or Thread For Http Connection?

Jul 5, 2010

I am a newbie in android and i had a question whether i should use a service or thread for http connection and what will be the advantage of using a service over a thread or viceversa. Please help me out with this.

View 13 Replies View Related

Android :: Does My Local Service Spawn Another Thread?

Jun 24, 2010

HTo be able to write "nice" code between my application/activies and a local service I need to understand some basic Android concepts:What I'm wondering is if my application (as in my activities) and my local service is sharing one thread. I.e. when the activities and the local service executes tasks queued are these tasks interleaved in ONE thread thus sharing the thread or does the service has a thread of its own?Also if the local service shares the thread with the activities and the local service makes a direct call (via a callback) to one of the activities (i.e. no post message) is the activity thread "halted" or is the execution of that specific function queued to be executed later anyway?

View 1 Replies View Related

Android :: Service Running On Seperate Thread

Nov 7, 2010

I have an application that starts on boot using a broadcast receiver, also I have an activity and a process, because the service must run always on the background I am starting the service on it's own process using the android:process manifest tag.The ui is only for presentational needs and I would like the user to be able to run the service even if the activity is not active.when I press the back button or the home button the activity's on destroy method is called and the service although seems its running (it appears on the task manager) its not behaving as supposed, it should connect to the net and send some data but every X time using an timer task but the task never fires so the data are never send.

View 1 Replies View Related

Android :: How To Run Thread In Service After Timely Intervals?

Nov 13, 2010

I need to create a service that runs a piece of code in new thread after (let us say) 10 mins. How can I do that? I have service ready but I don't seem to understand how (if ) to call timer from within thread.

View 3 Replies View Related

Android :: Advice On Structuring A Service / Activity / Thread

Oct 5, 2010

can someone please help me? I would like to write a program which uses a service to periodically update a text view on an activity. I do this by having ActivityA with a 2 buttons to start/stop my service. In the service I run a timer which triggers every second. From here I need to have this launch and update a text view on ActivityB which at present is just a counter value.I'm sure there are likely better ways to do this, such as using only one activity, maybe using a thread but the main design consideration is to have the service running even if my activity is destoyed (the counter value would instead go trigger some alarm or file write instead of a text view update). Sorry for rambling. I find the android developer resources offer too many solutions!

View 2 Replies View Related

Android :: Sync Between Local Service With Thread And Activity

Jun 1, 2010

I'm trying to think of a way on how to sync in between a local service and the main activity.

The local service has,

A thread with a socket connection that could receive data at any time.
A list/array with data.
At any time the socket could receive data and add it to the list.

The activity needs to display this data. So when the activity starts up it needs to attach or start the local service and fetch the list. It also needs to be notified if the list is updated.

I think I would need to sync my list somehow so the local service does not add a new entry to it while the activity fetches the list when connecting to the service.

View 2 Replies View Related

Android :: Difference Between Service / Async Task & Thread?

Jul 16, 2010

What is the difference between Service, Async Task & Thread. If i am not wrong all of them are used to do some stuff in background. So, how to decide which to use and when?

View 2 Replies View Related

Android :: Calling StopSelf In Service While Thread Is Running

Sep 14, 2010

Suppose I have code in the onStart() handler of my Service to launch a thread to do some stuff and then call stopSelf().stopSelf() gets called before the thread finishes.What exactly happens?I've tested this out myself and my thread continues to execute until it is finished.Does Android hear the stopSelf() call, but postpone it until the thread is finished?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved