android-service

Android Service - Can it pop an Activity?

I have three separate applications A, B and C. All of them use service S. When A, B or C connect to service S and service S must start, it must gather credentials from the user using form F. I want the user experience to go like this: From the Android main menu, the user taps one of the applications; A, B or C. Form F appears beca...

How to stop an Android Service ONLY when there are no other activities in my app running?

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

Start a short video when an incoming call is detected, first case using the emulator.

I want to be able to start a short video on an incoming phone call. The video will loop until the call is answered. I've loaded the video onto the emulator sdcard then created the appropriate level avd with a path to the sdcard.iso file on disk. Since I'm running on a Mac OS x snow leopard I am able to confirm the contents of the sdcard....

How to make Android Service run even when the device is not awake?

hi my application objective is to save location updates every ,let say, 20 minuets . I used service and it worked fine , but when i lock the screen or it is locked automatically the service stop running . when i unlock it , service runs again. highlight on my code: Service() onCreat(){ call timer(); } timer(){ code } How ...

Android - Having a service run every day at 4AM

Hello everyone, I would like to know the best practices for running a Service every day at 4AM. The way I think I should be doing it is to create a new repeating alarm using AlarmManager and having it run the service at 4AM. Problem is, I'm not sure where to put the code to set the alarm. Do I do it in my main activity as one of th...

Android service using components from other applications

I'm trying to write an Android application that will use plugins. These plugins will just be other Android applications without a launcher. For instance my application can fire an intent saying "I want to get a list of images". Then, the user can pick from which application he/she wishes to find the list of images (typical facebook-plugi...

Android Service interacting with multiple activities

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

Binding a Service to an android.app.Activity vs Binding it to an android.app.Application

Is there any fundamental difference in binding a service to an android.app.Activity vs binding it to an android.app.Application. I want to bind the service to an Application because I want to keep some global state/data in the Application instead of duplicating it in all my activities. Thanks. ...

Android - Launch notification from anywhere?

Hi y'all! I'm coding on the android right now, and I have an Activity which starts and stops a Service. However, related to this whole application will be a non-android java application which runs in the background alongside this app. I need this separate activity to be able to launch a notification, but I don't know how to do this. I c...

How to execute a remote service

I have a service MyService.java in Application "ServiceDemo". The manifest of this application looks like this <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.moto.dev" android:versionCode="1" android:versionName="1.0"> <application android:ic...

Android Service starts/binds correctly, but only the first time

Hi all, I have a service that starts and binds correctly when it's first called, but successive bindings to that same service fail when called by other activities. The code: activity.startService(new Intent().setClass(activity, ServerListenerService.class)); xmppServiceConnection = new ServiceConnection() { public void...

Good sample application for android service

Is there a good sample application for creating android services that run in the background? ...

Android : don't show Notification if app is shown

Hello, 1/I don't want to notify user if this one is already running my app in foreground, is it possible before create nofification to check if my app is not in front ? 2/if app is in background, is it possible to bring last state in front ? I know that Os can destroy some Activity, but is it possible to restore last state, don't s...

How to Create/Run AsyncTask in Service without runOnUiThread()

I have a Service that creates AsyncTasks for downloading files. In activities, we create Runnables or Threads that we pass to Activity.runOnUiThread(). I can't access that method from a service, so how do I use AsyncTask correctly, (do heavy work without blocking the UI Thread)? ...

Ways to notify activities of download completion

My application has an IntentService which runs periodically to download data from a remote server. The download task is run inside an AsyncTask which has reference to Application context only. The data downloaded is for entire application and is displayed across four different activities. When the download completes(AsyncTask completes)...

services in android

can anybody give example with service in android? Thanks ...

Aidl callback interface implementing another callback interface

I have a service with AIDL callbacks. I would like to know if it is possible to make an AIDL callback implement another AIDL callback in order to avoid multiple callback register For example : A.aidl : interface A { void doSomething(); } B.aidl : interface B implements A { void doSomethingMore(); } IService.aidl : interfac...

Obtain Android GPS location once every few minutes

I would like to write an app on Android to upload my GPS location to an external website once every ~5 minutes. This needs to have as minimal an impact on battery life as possible, but it also needs to work without any user interaction. (Background: I'm competing in an Ironman triathlon which will take me about 14 hours to complete, and ...

Android: When to use Service vs Singleton?

I'm quite new to Android development. When is it a good idea to create an Android Service instead of just using a simple Singleton class? Take, for example, the data layer downloading information feeds from the internet. Using a Service seems too much for some cases but sometimes I might need access to a Context so I'm a little unsure...

ConnetivityManager on Android

Is it reliable to save the connection state (i.e. save which connection is used and make connections and disconnections of sockets based on new states) ? ...