android-service

Kivy service stops when app is closed

泪湿孤枕 提交于 2019-12-02 13:23:35
问题 I'm starting a service from my Kivy app: service = autoclass('net.saband.myapp.ServiceMyservice') mActivity = autoclass('org.kivy.android.PythonActivity').mActivity service.start(mActivity, '') It works. And if I close my app using the back button my service still works. But if I close my app by swiping it out from the recent apps list the service dies. I've found this issue and tried to use startForeground guided by this article. It works but the notification is not removable so this

Should i call onCreate method in onDestroy method in android service?

自闭症网瘾萝莉.ら 提交于 2019-12-02 13:07:03
问题 I want to startservice again when it was destroyed. @Override public void onDestroy() { super.onDestroy(); onCreate(); } 回答1: You should not do this . This is not going to do anything. To restart a service you should restart it on onTaskRemove() like below. @Override public void onTaskRemoved(Intent rootIntent) { Intent restartService = new Intent(getApplicationContext(), this.getClass()); restartService.setPackage(getPackageName()); PendingIntent restartServicePI = PendingIntent.getService(

Service pauses on screen lock

ⅰ亾dé卋堺 提交于 2019-12-02 12:43:56
问题 For testing purposes i have made a service that beeps every 1 minute. (No client-server interface yet). It beeps okay when the screen in on, but when it goes to sleep the beeping stops. I am making an application that has to periodically poll the a server for something. For this, I am trying to create a service that'll constantly be running in the background, poll the server every 1 min and then based on the reply from server it shall generate a task bar notification. I have a test activity

Can accessibility service be stopped or killed?

拜拜、爱过 提交于 2019-12-02 12:16:26
问题 I have written an accessibility service and I want the service to be stopped/killed once it receives an accessibility event (i.e. in method onAccessibilityEvent ). Can this be done? I have tried to kill using kill process as below but it is not working. unbindService(mSvcConn); android.os.Process.killProcess(android.os.Process.myPid()); I have given the below permission in AndroidManifest.xml <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" /> I know that

how to make sure service is not killed

人盡茶涼 提交于 2019-12-02 11:54:41
问题 I am trying to write a music player in Android, and was trying to use service to play music in infinite loop in background. And I need the service to interact with the activity for volume control and so on. The question is, if I use service binder then the service will likely to be terminated with the activity when the activity is in the background. How to make sure the service can keep running without the activity and in activity some of the service's method can still be called? Is using

Android: How to detect when phone is active and idle?

时光毁灭记忆、已成空白 提交于 2019-12-02 11:42:07
问题 I want to create an app that will know when user is using the phone(start the screen and close the screen). After a period of time I need to call doSomething() method. Question: 1.How can I know when user start using the phone and when he close the screen? 2.Should I use Service or IntentService? Which is better in my case? 回答1: You can try something like this using a BroadcastReceiver and a Service: Your class using The BroadcastReceiver: public class ScreenReceiver extends BroadcastReceiver

Android: Which Background Service to use?

萝らか妹 提交于 2019-12-02 11:34:41
问题 I have an app where a user can perform a backup (offline) and restore (offline) on a button click. However, i don't know which background service is appropriate to use. Can someone advise me whether to use WorkerManager or Service in this case? 回答1: I recommend you to use ForegroundService as of the goal of using these services are Long Running Processes that Users should be informed and interact with it . Consider when you try to backup when you Use ForegroundService then you can show to

onPictureTaken never called

瘦欲@ 提交于 2019-12-02 10:24:18
The code works mostly fine. The only problem is that the onPictureTaken function never called. I need to use this function to store the image to SD Card. MainActivity public class MainActivity extends Activity { //private static Camera mCamera; //private CameraPreview mPreview; private static String TAG = "CamraOne"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_layout); Log.d(TAG, "setContentView end"); Intent intent = new Intent(this, CameraServiceOne.class); Log.d(TAG,"start intent"); startService(intent); Log

takePicture failed when running a Camera Service

自作多情 提交于 2019-12-02 10:00:24
im trying to run a Camera Service in the Background, as soon after the Service has started i get an error takePicture failed . I'm new to Android,new to Stackoverflow and also not a good programmer. I've added the right permissions and the service has been declared in the manifest file too. package com.example.nevii.camera; import android.app.Service; import android.content.Intent; import android.hardware.Camera; import android.hardware.Camera.Parameters; import android.os.IBinder; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.widget.Toast; import java.io

Android calling IntentService class from a Service Class

人走茶凉 提交于 2019-12-02 09:32:19
Can we call IntentService class from a running Service class . Intent myintentservice = new Intent(this, MyIntentService.class); startService(myintentservice); I using above lines of code in service class to start IntentService class. But then I get following error:- Process: objectdistance.ankeshkjaisansaria.ram.sita.cameratag, PID: 21823 java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference at android.content.ComponentName.<init>(ComponentName.java:77) at android.content.Intent.<init>(Intent