Android :: Background Service - Intents For Communication Between UI

Jul 6, 2009

I'm writing an application that consists of a background Service and one or several Activities acting as UI towards this. There will most likely be several different UIs for this service that will installed later on, like custom widgets or UIs. The question is how to solve this in the most efficient way. Is it better to only use Intents for communication between UI and Service (sending control commands with Intents from the UI and listening for Intents from the Service for state and data updates) or should I prefer using IPC communication (AIDL -> Java Stub, binding to the service etc.)?

Since the UI might be started long after the service is started, I would either need to use sticky intents to signal current state, or have a very frequent intent sent by the service if choose to go with the Intent-based design. Which one would be the preferred way in that case? I've read that sticky intents are much more resource consuming than normal intents, but are intents more consuming than IPC directly towards the service? Also, is really an AIDL the right way to allow third-party integration? Intents sounds better, since they are also asynchronous.

Android :: Background Service - Intents for Communication between UI


Android :: Backround Work / Use Service For Communication?

Dec 21, 2009

This is the scenario:
1 user has a main activity used for ii.
2 program needs to communicate with peers and keep connection and wait for messages
3 when a message comes it is shown in the main activity. so the question is should I use a service for the communication and what type of service? and also should I use Aspects in the service in order to keep my ii responsive and why?

View 1 Replies View Related

Android :: Communication Between Activities - Intent Or Service - Faster

May 3, 2010

Is there a significant difference in time needed for sending data over a service or by using an intent?

Are there general advices when to use service and when to use intents?

View 4 Replies View Related

Android :: Boasts Certain Features Like Communication Via GPRS Service

Nov 12, 2010

I am a junior software developer working mostly in c#. I am being tested at work by my boss for a new role as an android sdk developer. I passed the first interview and now he wants me to write a small application which boasts certain simple features such as communication via GPRS service and handling data (i guess he means use a sqlite table to store some input). Anyone got any simple ideas you can throw at me to give me a good starting point.

View 3 Replies View Related

Android :: Inter-process Communication With A Service And Notifications

Dec 13, 2009

I'm having an issue with inter-process communication with a Service and Notifications

The structure of my application is as follow: - ListActivity (TunnelDroid), once the user presses a listitem it will start a Service. The ListActivity is binded to the service for intra-process communication

- Service (TunnelManagerService): running in the background. This service will add a (permanent) Notification in the statusbar. Using a Handler I sometimes need to communicate with the ListActivity (to show GUI Dialogs)

- Notification: Once this notification is clicked it should open the ListActivity.

To add the action when the user touches the notification I use the following code: notificationIntent.setClassName("net.sourceforge.tunneldroid","net.sourcefo­rge.tunneldroid.TunnelDroid"); Then I use the intent to create the notification.

Unfortunately a new Intent is opened. When I press the back button the original ListActivity is shown. So I have two instances of my same class/list.

How could I make sure the original ListActivity is opened when the user touches the Notification?

It's OK for me if the original ListActivity was previously destroyed, but I cannot have two instances. The problem is that the Handler in the Service has a reference to the ListActivity (PARENT_ACTIVITY), so if another instance is created I have invalid references. I could overwrite the PARENT_ACTIVITY, but then when the user presses the back button I have an instance with no correct link to my Service resulting in a crash/nullpointer.

The complete source can be found here: http://tunneldroid.svn.sourceforge.net/viewvc/tunneldroid/tunneldroid. Attached you can find a drawing of (most of the) inter-process communication. Could someone point me in the right direction?

View 3 Replies View Related

Android :: How To Establish A Two-way Communication Between Activity And Service In Different Process

Mar 19, 2010

I'm working on establishing a two-way communication between an Activity and a Service which runs in a different process.

Querying the process from the Activity is no big deal. But I want the process to notify the Activity on events. The idea behind it is this: the service runs independently from the actual app. It queries a webserver periodically. If a new task is found on the webserver the process should notify the activity.

I found this thread over at AndDev.org but it doesn't seem to work for me. I've been messing around with BroadcastReceiver. I've implemented an interface which should notify the Activity but the problem is that the listener is always null since the Broadcast from the process is done via Intent, hence the class that extends BroadcastReceiver will be newly instantiated.

How can I establish a 2-way communication? This has to be possible.

View 3 Replies View Related

Android :: How To Use Intents From Service Or Broadcast Receiver?

Dec 15, 2009

I need to be able to handle/catch Intents while my Activity is closed. So I am looking at either a Service or a BroadcastReceiver. Is it possible to "receive" intents to a service itself? I tried to search, but could not find anything helpful. With a BroadcastReceiver, I am not exactly sure how that works outside of an Activity. Does it depend on the Activity being open/running? Can it run by itself?

Let's say that my Activity is killed by Android(or a task killer app), does the BroadcastReceiver still receive intents and process them? I have used a BroadcastReceiver as a widget, but I do not want to use a widget this time. My goal is to have the user open the Activity to set some options. From there, they would be able to close the Activity, but I would still be able to process Intents that were sent out by the system. I am still fairly new to Android development, so I could be so far away from where I need to be.

View 1 Replies View Related

Android :: Communicate Between Applications (service Vs Intents)

Sep 13, 2010

What is the difference between 2 ways of interaction between applications on android:

1. implementing service in app #1 and using it in app #2.
2. handling intentions and posting answer intention.

View 2 Replies View Related

Android :: Efficient Way Of Updating UI From Service Than Intents?

Apr 12, 2010

I currently have a Service in Android that is a sample VOIP client so it listens out for SIP messages and if it recieves one it starts up an Activity screen with UI components. Then the following SIP messages determine what the Activity is to display on the screen.
For example if its an incoming call it will display Answer or Reject or an outgoing call it will show a dialling screen. At the minute I use Intents to let the Activity know what state it should display. An example is as follows:

Intent i = new Intent();
i.setAction(SIPEngine.SIP_TRYING_INTENT);
i.putExtra("com.net.INCOMING", true);
sendBroadcast(i);
Intent x = new Intent();
x.setAction(CallManager.SIP_INCOMING_CALL_INTENT);
sendBroadcast(x);
Log.d("INTENT SENT", "INTENT SENT INCOMING CALL AFTER PROCESSINVITE");

So the activity will have a broadcast reciever registered for these intents and will switch its state according to the last intent it received...............

View 2 Replies View Related

Android : How To Call Service By Intents / Programmatically?

Nov 1, 2009

I'm rather new to Android, so please bear with me. I'm developing an application running a service in the background. The service is ONLY supposed to run when requested somewhere in the UI. The service must be able to be stopped through the UI as well. At the same time, while running, the service must be able to pick up intents such as "intent.action.DATA_SMS_RECEIVED" and "intent.action.NEW_OUTGOING_CALL".

View 2 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 :: Use Of Intents Used For Sending Data To Activity From Service

Feb 16, 2010

I am little confused with the use of intents used for sending data to activity from service. In my application I have to have startactivity from the service and have to pass data ,so that activity can utilize the data while launching.For this i have written the following code Intent intent = new Intent(Service.this,Activity.class); intent.putExtra("data", data); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.start Activity(); I assume that the data is passed to the activity and can be parsed on the oncreate function of the activity.Now the service running in the background has to pass data to the activity continously for UI updates.For this I have written the following codeIntent intent = new Intent(Service.this, Activity.class); intent.putExtra("Data", data); intent.setAction(Intent.ACTION_ATTACH_DATA); sendBroadcast(intent,null); (Do I need to broadcast the intent???) In activity I have done following things:- Implemented broadcast reciever:private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_ATTACH_DATA.equals(intent.getAction())) { Bundle extra = intent.getExtras(); float Data[] = extra.getFloatArray("Data"); update(Data);

View 4 Replies View Related

Android :: Sending Intents From Receiver To Service With Delay

Aug 18, 2010

I have a Receiver for BOOT_COMPLETED intent and it will start a Service by calling startService with an intent and the Service processes that intent in onStartCommand function by spawning a thread that does a HTTP post to a server.On powerup, sometimes it takes 3 to 5 seconds to get the active data connection on phone, when this happens Service fails to do HTTP post as there is no data connection. Is it possible for the Receiver to send the intent to Service using startService with a delay.? so that when onStartCommand of Service is called data connection is ready to post data.

View 2 Replies View Related

Android :: Passing Intents From Service To New Launch From Main Activity

Mar 30, 2009

How do you pass an intent from a service to a new activity launched from a main activity? There's a passextra( intent src ); but I don't think thats what I am looking for?

activity main > start service( intent wuteverserviceintent );
activity main > start activity( intent newactivityintent );

View 2 Replies View Related

Android :: Unable To Get Data From Activity To Service / How Intents Could Pass That?

Nov 24, 2010

I am pretty new to this but I was told I could get good help here. A friend and myself are playing around with creating Android apps (using ADT)

Here is how we are trying to make the program: in activity, user sets threshold values for the X and Y axis on accelerometer. When user hits button "Start", startService is invoked and starts TiltService.

TiltService is designed to run in the background always on the phone without user interaction. TiltService constantly compares the threshold with the accelerometer values and will vibrate if they are off.

My problem is I can't seem to get the putExtra() data correctly. I have overridden the onStartCommand in my service but I get the message "unreachable code" when I save the getExtras() to a bundle.

Here is the relevant code (I can post the whole thing, just do not want to clog up page) code...

I thought I understood the basic of how Intents could pass data, but I guess I don't. Is it obvious what I am missing?

View 2 Replies View Related

Android :: Service Restarted With All Unfinished Intents That Returned Start Status START_REDELIVER_INTENT?

Nov 1, 2010

Suppose you have a download service that downloads files asynchronously. For each download intent received it will put the URL of the file to download and the start ID into a job queue and return START_REDELIVER_INTENT. A worker thread then processes that list and calls stopSelf with the start ID it just processed. My question is: If the service's process gets killed and the service restarted, will the service receive all the intents (with the URLs) it hasn't called stopSelf on before it was killed or does the service receive the last intent only? It seems the API docs are ambiguous on this.

The docs say

"if this service's process is killed while it is started [...], then it will be scheduled for a restart and the last delivered Intent re- delivered to it again [...]", indicating that only the last intent gets redelivered (which would be terrible in this use case), but they also say "The service will [...] be re-started if it is not finished processing all Intents sent to it (and any such pending events will be delivered at the point of restart)."

View 4 Replies View Related

Android :: Possible Bug With Intents / Pending Intents

Nov 7, 2009

I have some code that is creating and removing alarms, and which works great in Android 1.5 and 1.6 but breaks on the Android 2.0 AVD.The code that's giving this exception is: Code...

View 3 Replies View Related

Android : Need To Always Run A Service In Background

Apr 2, 2010

I am in the process of creating an app that is similar to the build-in SMS app. What I have tried: - running a regular service which worked just fine until android kills the service - using the AlarmManager the make the 5 min. interval call to a service. But I was not able to make this work.

View 2 Replies View Related

Android :: Want To Develop A Service That Needs To Be Run In Background

Jul 15, 2009

I'm trying to develop a service, which needs to be run in background as a low priority task and does some complex processing . I need to gracefully quit my service when their is a resource shortage( like CPU running low on memory). Was there any APIs available to know the CPU resource usage, Objectives of my service is to - 1. Exit service when a high priority application(s) is running and which might need entire CPU resources. 2. Should store my states before onDestroy() of my service is called.

View 3 Replies View Related

Android :: Show Pop Up From Background Service

Sep 15, 2010

it is possible in android to show pop-up dialog from background running service?

View 1 Replies View Related

Android : Is It Possible To Use Accelerometer In A Background Service?

Sep 9, 2009

It seems trivial to use GPS in a background service, but how can you do the same with the accelerometer? Everything I've tried seems to require a context, but a background service doesn't have a context?

View 5 Replies View Related

Android : Way To List Background Service

Apr 22, 2010

I like to check my service status, e.g. live or be killed. so, I hope there is a command like "ps -ef " of linux.

View 2 Replies View Related

Android : Background Service Is Not Working

Nov 24, 2009

I wish to use implement Service in my application to display a message on the screen. This service should run while my application is running. But right now, i just want to test the service function and the Service doesn't seem to work well. In the main java file, i call startService(new Intent (this,testing.class)).

View 8 Replies View Related

Android : Why Use Service For Background Tasks?

Nov 2, 2010

An activity can use AsyncTask or Handler framework for background work. Both will continue to work even after user has moved away from the activity that started them and the onDestroy for the activity has been called. In other words, an activity is fully capable of doing background work even after its GUI has been shutdown.In this scenario, use of Service for background work seems like redundancy. What does Service bring to the table that an activity can not do?

View 3 Replies View Related

Android :: File Downloading With Service In Background

Nov 14, 2010

When I download a file from web in android, then I want to show a progress bar in notification area of status bar through service, but I am not able to do this. How can i do it? I am not able to pass the file length in service. I am giving URL in EditText, and I am clicking Download Button. After Click A class will be called on Click Listener, this class is having a function. In that function I am doing processing or functionality of downloading, Now I want to show the progress bar in Notification Area Through service, but I can not able to do this.

View 2 Replies View Related

Android :: Start Background Service On Install

Oct 22, 2010

I have an app which runs as a background service only. I'l like it to start up when its installed. As its just a background service it doesnt show up on the pane of installed apps. So there is no way for the user to manually start it. I've already regietered for the BOOT_COMPLETED intent which works but I dont want the user to have to power off the phone after the app has been installed, just so as they can start it.

I've looked at the following intents: ACTION_PACKAGE_ADDED/CHANGED/ REPLACED/RESTARTED/INSTALL, ACTION_SCREEN_ON/OFF, ACTION_USER_PRESENT, ACTION_TIME_TICK,

But it doesnt seem that you can register to listen for them from my manifest.

How I can start my background service without a power off/on?

View 2 Replies View Related

Android :: Calling Background Service From BroadcastReceiver

May 24, 2010

I am trying to call a push notification background service from BroadcastReceiver class, but my application crashes.When I call this service through an Activity it's working, but my goal is to call this service from a BroadcastReceiver.

View 2 Replies View Related

Android :: Running Background Service That Would Disable SMS

Jun 25, 2010

I'd like to include a feature in my application that would include a running background service that would disable SMS, if certain conditions were met (location for instance). Is there a way I can intercept the user wanting to open any SMS app and block it? Would a Broadcast Receiver be able to do the trick? Maybe a different way to go about this?

View 3 Replies View Related

Android : Difference Between A Background And Foreground Service?

Aug 21, 2010

I am currently writing my first Android application and I keep running into references to background and foreground services. Since I intend on using a service in my application I was hoping to get a clarification between the two and how they are used.

View 1 Replies View Related

Android : How Can We Call Webservice Through Background Service?

May 19, 2010

I am using a web service. i have to start that particular service at every 6 hrs interval, automatically . i want to perform this task with alarm manger. but i have no idea.

View 2 Replies View Related







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