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?

Android :: Communication between Activities - Intent or Service - faster


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 :: 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.

View 12 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 :: Unable To Start Service Intent Service Not Found

Aug 20, 2009

I am getting following message when i try to launch service.Also is there any specific path on file system where we need to place the .apk file which contains my serivce component only.

View 2 Replies View Related

Android :: How To List Activities Which Match An Intent?

Apr 17, 2010

I have a few separate applications which are all launched purely through a main application.I am wondering if I'd be able to use intents to retrieve a list of all the sub-applications which match some discovery intent. The main application currently needs to know what Intents to use to START these sub-applications, but is there a way to use intents to see if other Activities on the device match a set of intent-filters?

View 1 Replies View Related

Android :: What Intent Flags Are Recommended For Activities Started By Notifications

Nov 8, 2010

I am running into a peculiar issue with an app which has multiple Activities.I have a screen manager class that is bound to a service.The service polls a server for data.The screen manager starts Activity A, B, or C, based on the data.It will also allow the user to select to display the other Activities or it may swap out an Activity automatically based on new data from the service.Currently all the navigation works great and if the user presses Home, the applicable Activity comes back to the foreground when the user presses the apps icon from the Android home screen or the recently run apps list.I then had to implement a new feature to display an icon and notification.I first implemented this by only displaying the notification when the Activities were no longer visible by setting it in each Activities on Pause.Worked like a charm and gave the user a third option to redisplay the app after Home button press.However if the data from the server (when the app is not displayed) causes the screen manager to update the Activity to be displayed I have issues. I think my Activity stack is getting screwed up.I have since tried a little different model where the screen Manager handles the notifications and always displays the notification, updating it with a new Intent whenever an Activity is updated, but its still not cutting it.

When the app is minimized and the data changes I can see the screen manager call the startActivityForResult on the new Activity and it seems like Android knows we are minimized and does not display the Activity. I can then also the screen Manager call to finish on the old top Activity.Each Activity currently has the flag set to singleTop in the manifest and FLAG_ACTIVITY_SINGLE_TOP in the code. When the data hasn't changed on the server, I pull the app back up using any of the above I get what I expect and the Activity's onNewIntent is called. However when the data has changed and the user calls up the app via the notification it calls the Activities onCreate. The Activity does come up and runs, but then pressing back takes me to what seems like another instance of the same Activity instead of exiting. I just took a closer look at my logcat and I see 2 calls to the Activity's onResume, but then no doubles after that.

View 1 Replies View Related

Android :: Reloading Our Activities State After Firing Intent To Camera

Aug 31, 2009

We have an Activity which has a form on it and we launch an Intent to take a picture.We've overridden onSaveInstanceState and onRestoreInstanceState to push the data from the view fields But, on the return from the CameraActivity, the onRestoreInstanceState method is never called. Should this behavior work when calling another Intent?

View 7 Replies View Related

HTC EVO 4G : Will Being In No Service Area Drain The Battery Faster

Jun 7, 2010

I started a new job today, the training room somehow manages to get no service. My phone died in about 7 hours, I used it for about 10 mins total.

All weekend I got much better results, with it coming in and out of service do you think it's draining it faster? Only thing I had turned on was gps location. I would like to keep it on so I don't have to power it up on breaks and wait for any missed messages to come through.

View 6 Replies View Related

Android :: Managing Activities From Service

Jun 1, 2010

I have a service that listens to the serial port. According to data received from serial i switch between particular service states, and start particular activities on state transitions. I would like to accomplish it in following way: Let's assume there is one active Activity1 started from previous state, I call startActivity from service to start a new one Activity2, but I want to simulatenously destroy Activity1 when Activity2 gets on top of the stack. I tried to call finish() in Activity1.onStop but it seems not to work (Activity1.onDestroy() doesn't get called). I'd prefer to finish Activity1 after Activity2 gets on top in order to avoid blinking.

View 5 Replies View Related

Android :: How Many Activities Bound To Service

Sep 11, 2009

I have a service that's running in the background, is there any way (short of keeping a count of onBind() and onUnbind()) to know the number of activities that are bound to it?

I am trying to provide a "quit" function. all my activities derive from the same base class. I am keeping a global static around that says the "quit" button was pressed. then on each of the activities onResume() method, I look for the global static "quit" variable and if it's set to true, I call "finish()" so my activity shuts down, and then next activity on the task stack appears -- which goes through the same process of checking the global static "quit" variable until it gets to the root activity -- which effectively goes back to the main desktop screen.

However, I need a way to reset the global static "quit" variable, otherwise, when I launch the app again, it will check the global static quit variable and shutdown immediately - never coming back up. So, I want to know if there are any activities bound to my service, if not, I would set the global static "quit" variable back to false so that the app could be relaunched again.

View 2 Replies View Related

Android :: Service - Communicate With Activities

May 19, 2010

I'm wondering which is the best way to communicate between a Service and an activity..

Broadcast intent
Callback
others?...

View 1 Replies View Related

Android :: Service - Not Bound To Any Activities

Jun 5, 2010

I have an Android Service that I would like to keep running even after the last Activity has been popped off the stack, or the User has chosen to do something else.

Essentially the Service is listening for changes on a remote server, and I would like to generate a Notification if and only if an Activity from the app isn't running(or visible). In other words, I don't want the Notifications to occur while the User is directly interacting with the app.

In the case where the User is directly interacting with the app, the Service will notify the Activity and update appropriate UI elements based on the changes. I plan to implement this through the Observer pattern.

How can the Service know if none of apps Activities are bound to it?

View 2 Replies View Related

Android :: Service By Mean Share By All Activities

Aug 27, 2010

Android: i want to create service by extending a Service class which i start when application get started and all activities can share its state and when i want stop it from other activity and when i want start it again from any activity ?

View 1 Replies View Related

Android :: How To Stop Service - When All Activities Are Finished

Jan 26, 2010

I am programming a game. I have a service for the background-music. When I press the home-button and leave my activities, the service still runs in background. How can I stop the service, when there is no more visible activity in my program and restart it, when the user goes back to my game (some activity of it)?

View 8 Replies View Related

Android :: Stop Service Only When There Are No Other Activities In App Running

Mar 13, 2010

Is there a way I can test if there are any other activities in my app still alive? I am looking to stop a service in an onDestroy method, but only want to do this if there are no other activities from my app still alive on the stack.

I have the call stop the service in the main activity's onDestroy() method. This works perfect EXCEPT that if a user launches my app, then launches a few activities in my app, then hits the home screen and RELAUNCHES my app, they will subvert my order and the main activity will now be above other activities of my app. From this state, if they hit the back button and 'back out' of my home screen they will trigger the onDestroy() method and kill the service even though there are other activities open on the stack. I want to avoid this by stopping the service ONLY if I am sure there are no other activities of mine open on the stack.

View 1 Replies View Related

Android :: Service Object Availability Between Activities

Apr 3, 2010

I currently have a service called ConnectionService. It instantiates a Connection object that gives me access to a controller of TCP.

I start the service from a splash screen activity, which sends and intent and starts my "main" activity once a connection has been established. In the "main" activity, I can access my Connection object and communicate with the controller. However, when I start a new activity from the "main" activity and bind to the service, I get a NullPointerException when I try to call methods in the ConnectionService.

View 11 Replies View Related

Android :: Using Socket In Service Communicating With More Activities

Aug 29, 2010

I want to create an application to remote control my PC.

For example: Volume (get actual volume level, increase/decrease/mute volume), TVtime (start/quit tvtime, get actual channel, toggle fulscreen, channel up/down, toggle input source, toggle aspect ratio), Amarok (start/quit amarok, get current song, prev/next song, play/stop/ pause), etc.

The application for the PC is done (in python). The communication protocol used is very simple.

For example: "volume:get_level", "volume:up", "volume:mute", etc. Now I'm working on the android application.

What I have implemented till now is to create an activity, with: - an edittext to enter host:port - a button to connect/disconnect to/from server - the onCreate method creates a new thread for socket communication to send/receive messages to/from PC. - a textview to display information received from PC (eg. volume level) - a button to send command to PC I'm using handler to communicate between the tcpclient thread and the main activity.

It is working... But I want to use more than 1 activity. I want to use different activity for every program controlled. Searching for a solution to transfer the thread's handler to a new activity I have found that it is not possible, and I have to use a service.

So, my question is: how to send message from different activities to the same service, how to send message from service to the actual activity and how can I check in the service which is the actual activity? Because the service is running in the same thread as the activities I suppose that I still have to create a new thread for socket communication. How can I send the data received by the socket to the service?

View 5 Replies View Related

Android :: Multiple Activities Binding To A Service

Aug 3, 2010

I have a service component (common task for all my apps), which can be invoked by any of the apps. I am trying to access the service object from the all activities, I noticed that the one which created the service [startService(intent)] has the right informaion. But rest does not get the informaion needed.

My Code is as below:

CODE:................

If I invoke startService(intent). it creates a new service and runs in parallel to the other service.

If I don't invoke startService(intent), serviceObj.getData() retuns null value.

View 1 Replies View Related

Android :: Service Interacting With Multiple Activities

Jun 29, 2010

I'm trying to refactor/redesign an Android app. Currently, I've one UI activity (Activity 1) that creates a DataThread. This thread is responsible for network I/O and interacts (provides data) with the UI activity via a handler.

Now, I want to add another activity (a new UI screen with Video) - Activity 2. Activity 1 is still the main activity. Activity 2 will be invoked when the user clicks a button on Activity 1. Activity 2's data also comes from the DataThread.

My idea is to put the logic of my DataThread inside an Android Service (DataService). My question is - can more than on activity bind to my DataService at the same time? Is there a way to tell the service to provide data to a specific activity only?

View 1 Replies View Related

Android :: Bind Service To Multiple Activities Advice

May 19, 2010

I'm new to Android development and am working on a small test project. I have a service, which communicates with an SQLite3 database, and two activities. A main activity which fetches database information via the service and displays it and a second activity which allows me to add data to the database via the service.

Currently, I have a singleton class which implements the ServiceConnection interface and I'm binding this to the service in the the main activity using the bindService function. Because it's a singleton, I can then use this service connection in both the main activity and second activity to work with the database and it all seems to work quite well.

However, I'm all the time aware that the service connection is bound to the main activity and I'm wondering if this is the wrong/bad way to do it? Would I be best off having two service connections, one in each activity, and binding each to the service?

View 2 Replies View Related

Android :: Handling Events From One Service For Multiple Activities

Jun 10, 2010

I have a class A which extends TabActivity and creates Activities B, C and D as tabs in its onCreate() function. Also, class A initializes another service handler class S which is responsible for establishing a connection to a service and implementing callback handlers for the service. Any of the Activities B, C and D should be able to receive events from the service and update accordingly. If I receive any event in class S from the the service then I want to call a function in Activity B which would be responsible to update the UI elements in Activity B based on the event received. You can assume that the user is in Activity B when the event arrives.

Can I call an activity function like the following in the stub handler for the callback in my class S -

CODE:................

View 4 Replies View Related

Android :: One Local Service Multiple Binding Activities

Nov 20, 2010

I have a local Service to which multiple activites needs to bind. In the first launched Activity, bindService returns true and onServiceConnected is called. But in any additionally launched activites bindService returns false, and I can't get a reference to my Service.

How can multiple activities simultaneously be connected to a local Service?

View 3 Replies View Related

Android :: Want Connected To Phone Service Between Multiple Activities?

Jan 15, 2010

I have multiple activities and one service.. In MainActivity I successfully connect to service (using a class what implements ServiceConnection + bindService() + startService()) but when i try to apply same method in other activity i see in LogCat a error... It Is possible to connect to service in an other way: something like to make static my CounterServiceConnection object in MainActivity and use it in the second one?

View 2 Replies View Related

Android :: Service Change Values Of Variables And UI Textfields Of Activities

Oct 20, 2010

I have an application that get/send data from/to a remote DB on internet.

I need to get my application working in background mode, then i supose that i have to put all the send/get remote data in a service..... but.... How can this service change values of variables and UI textfields of my activities? i can't find any information about this, all the tutorials i am finding are of simple services that doesn't do something like that.

View 7 Replies View Related

Android :: Background Service To Recode Different Activities And Upload On Server

Sep 9, 2010

I want to know that how i can get these things in android.Recording of Calls Appointment/Calendar Logging Bookmark Logging Browser History Logging Contact Details Location Through SMS SIM Change Notification and after getting these things in a file (.txt, xml, or CSV) how i can upload these things to my php server by running a backgroud service.Service will now prompt user again and again. Everything will be recorded silently and then user will see this information on server whenever required.

View 2 Replies View Related

Android :: Ue Intent In Service?

Aug 3, 2010

I want startActivity in the service.first I new Intent(),but I don't know how to new Intent().Because Activity and Service don't together project.I don't know Intent how to find this Activity.

View 2 Replies View Related

Android :: UI Blocking On Intent Service?

Sep 14, 2010

I'm launching an IntentService using startActivity from inside the onClickListener of a button. startActivity returns immediately. No blocking there. But the button stays "pressed" until the IntentService finishes its work. In addition, the screen does not respond to rotation while the IntentService thread is running. I can see that it's a separate thread in the debugger but the UI seems to be coupled to it. As soon as the IntentService thread finishes, the UI is unblocked. Any idea how I can prevent this and let the UI continue?

View 2 Replies View Related







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