android-service

Continue Service even if application is cleared from Recent app

眉间皱痕 提交于 2019-12-17 03:24:31
问题 I am having a little issue. In my application, a Service is started after user is logged in successfully. Previously, the service needed to stop if application was killed. (say, removed from Recent application list by swiping.) So we had used android:stopWithTask="true" . Now we need the Service to run as it is, even if the Task which started it, is removed from Recent app list. So I changed the Service to include android:stopWithTask="false" . But that doesn't seem to work. Related code:

How to simulate touch from background service with sendevent or other way?

烂漫一生 提交于 2019-12-17 03:23:52
问题 Is it possible to simulate touch from the background application (or service) or to run sh script (that simulate touch)? It is needed for testing android system without USB or other connection to PC, thats why I can't (or don' know how) use Monkey or other autotest tools. Added info: I found the way to run shell commands with root (tested devices rooted): Unable to execute sendevent shell command through the android code (create touch simulation). Writing file on system partition (run

Launch Android application without main Activity and start Service on launching application

折月煮酒 提交于 2019-12-17 03:22:41
问题 I have the following scenario in my application. There is no UI in my application; instead there is a Service which starts on boot up and will continuously run. How can I configure my manifest file without a main Activity? Can I launch my app without any Activity? And on launching my app, my Service should start. Is this possible? I don't want to make a translucent Activity to start the Service. 回答1: You said you didn't want to use a translucent Activity, but that seems to be the best way to

Creating an Android Service with Phonegap? (Have phonegap app run even when closed)

限于喜欢 提交于 2019-12-17 02:07:26
问题 I have been working on an Android app using Phonegap and now would like to make it so when the app is closed it can still execute the java/js code in the app. So I understand I need to create a service. If I create a service plugin on phonegap can I still execute the javascript code or only the java? Has anyone does something like this? I found this discussion but did not seem to work: http://groups.google.com/group/phonegap/browse_thread/thread/722b0e796baa7fc6 So that is all I have right

START_STICKY does not work on Android KitKat

元气小坏坏 提交于 2019-12-17 00:47:42
问题 One of my apps has a backgrouod service that uses the START_STICKY return code from onStartCommand to automatically restart when the system kills it. It seems that this is no longer working on Android KitKat. Is there any solution for this ? Should I be doing something different on Kitkat to keep the service running ? Note: There is a similar discussion on the Android-Devlopers group about swiping the app from the recent apps list behaves. Could this two issues be related ? https://groups

How to check if a service is running on Android?

∥☆過路亽.° 提交于 2019-12-16 18:54:05
问题 How do I check if a background service is running? I want an Android activity that toggles the state of the service -- it lets me turn it on if it is off and off if it is on. 回答1: I had the same problem not long ago. Since my service was local, I ended up simply using a static field in the service class to toggle state, as described by hackbod here EDIT (for the record): Here is the solution proposed by hackbod: If your client and server code is part of the same .apk and you are binding to

Listener for media button (headset-hook) using service without Activity

笑着哭i 提交于 2019-12-14 02:39:59
问题 How can I make service listen for media button (headset-hook) in android device . I try to do that using this code but did not work. Can you help me. Service code: public class RLservice extends IntentService { private Handler handler; public RLservice() { super("my service"); // TODO Auto-generated constructor stub } @Override public int onStartCommand(Intent intent, int flags, int startId) { handler = new Handler(); return super.onStartCommand(intent, flags, startId); } @Override protected

Android: Singleton Instance vs Service

混江龙づ霸主 提交于 2019-12-14 02:06:12
问题 Here I want to ask one basic question which I couldn't find the answer while iam doing code. As I understand, creating a singleton instance in application onCreate() is having less vulnerable than android service. In my application, i want to listen for location update which should have less likelihood to get destroyed. If I keep service it might get killed in low memory but still, the application can run in the background which would keep the instance. So I would like to go with singleton

Why is it important to use Services for background tasks?

我们两清 提交于 2019-12-13 20:29:27
问题 I know I should use Services in Android to do stuff in the background from a non-UI thread. However, I would like to know what is wrong with just spawning a background thread to do the work from an Activity class (within an onClick event for example). Thanks in advance. 回答1: Actually, Services are used for long running tasks, especially those, that run when your activity is not running. Threads can be used for making some tasks inside your activity. This states, that a Thread , created inside

Android: intent.getExtras().getSerializable(Constants.codiceMainActivity) is null

北慕城南 提交于 2019-12-13 20:12:33
问题 I want to start a service from my main activity and pass an object with Serializable. However when I get the object in the Service and I call a method, it is null and I don't know why. Here is my MainActivity class: public class MainActivity extends AppCompatActivity implements View.OnClickListener, Serializable { private transient SetVocabulary setVocabulary; private transient Intent intent; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);