android-service

Touch event.getAction does not work under service class in android studio

删除回忆录丶 提交于 2021-01-12 06:27:23
问题 I developed an App to collect touch events under the foreground service class. The app has a main activity to input user's information (e.g., name and age). Then a foreground service starts to collect touch events, and a notification is launched to inform the user that the service is running. This is the main activity code public class MainActivity extends AppCompatActivity implements View.OnClickListener { @Override public boolean onOptionsItemSelected(MenuItem item) { Intent intent; switch

java.lang.IllegalArgumentException: Service not registered

别来无恙 提交于 2021-01-03 07:51:08
问题 I have a app which contains webview. Every thing is going well but in my run tab in android studio. I am getting below message. My app still working fine. But it still bugging me. I don't know much about this message. Exception thrown while unbinding java.lang.IllegalArgumentException: Service not registered: lx@643d3c7 at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1526) at android.app.ContextImpl.unbindService(ContextImpl.java:1717) at android.content.ContextWrapper

java.lang.IllegalArgumentException: Service not registered

我们两清 提交于 2021-01-03 07:49:12
问题 I have a app which contains webview. Every thing is going well but in my run tab in android studio. I am getting below message. My app still working fine. But it still bugging me. I don't know much about this message. Exception thrown while unbinding java.lang.IllegalArgumentException: Service not registered: lx@643d3c7 at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1526) at android.app.ContextImpl.unbindService(ContextImpl.java:1717) at android.content.ContextWrapper

Android getContext on a background Service

雨燕双飞 提交于 2021-01-02 06:50:31
问题 I'm trying to create a Service that runs even when my app is closed. However, I need to use my app Context inside this Service . When the app is running, the service works as well, but when I close the app (onDestroy() was called), the getContext() always returns null . Service public class SubscribeService extends Service { private Context context; @Override public IBinder onBind(Intent intent) { return null; } @Override public void onCreate() { super.onCreate(); context = this; //Returns

Disable service restart on button click

让人想犯罪 __ 提交于 2020-12-16 02:30:20
问题 I start a foreground service that downloads a file when users click on a button. What happens now is when I click again on the button, the thread inside service starts second time and I see in a notification that progress is updated for both threads (jumps presentae between threads). How can I prevent starting the second thread in case the first one is running, how can I prevent startService() or onStartCommand() is being called if the service is still running? class ForegroundService :

Disable service restart on button click

六眼飞鱼酱① 提交于 2020-12-16 02:22:48
问题 I start a foreground service that downloads a file when users click on a button. What happens now is when I click again on the button, the thread inside service starts second time and I see in a notification that progress is updated for both threads (jumps presentae between threads). How can I prevent starting the second thread in case the first one is running, how can I prevent startService() or onStartCommand() is being called if the service is still running? class ForegroundService :

Android : Call a Fragment Method from a service

做~自己de王妃 提交于 2020-12-15 06:46:24
问题 Have a Firebase Cloud messagin Service running , and i want each time i receive a new message a methode in a specif fragment is called. public class FirebaseMsgService extends FirebaseMessagingService { public FirebaseMsgService() { } @Override public void onMessageReceived(RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); ServiceConnector serviceconnector =null; JSONObject data; String json = remoteMessage.getData().toString(); try{ data= new JSONObject(json); **Fragment

How to take a Screenshot from a background-service class using MediaProjection API?

巧了我就是萌 提交于 2020-12-15 06:17:30
问题 After doing a lot of research on this topic, though I found a few answers, I could not understand how the MediaProjection API works. I want to take a screenshot of the device from a background Service class. Is it possible to do it. I have one MainActivity.java which starts a serviceIntent to another class which is a service(not an activity). So I want to implement this API in this service class. Please help me 回答1: This is tricky way to achieve this. First of all you need to create

How to take a Screenshot from a background-service class using MediaProjection API?

有些话、适合烂在心里 提交于 2020-12-15 06:16:11
问题 After doing a lot of research on this topic, though I found a few answers, I could not understand how the MediaProjection API works. I want to take a screenshot of the device from a background Service class. Is it possible to do it. I have one MainActivity.java which starts a serviceIntent to another class which is a service(not an activity). So I want to implement this API in this service class. Please help me 回答1: This is tricky way to achieve this. First of all you need to create

android studio service doesn't work when i clean my app

筅森魡賤 提交于 2020-12-15 01:46:48
问题 I use service to push notification when someone receive message,and my service works well when i open the app and close the app,but when i clean my app,it just stop.Is it the problem that i write my own startForeground instead of using the startForeground they gave?it was work at the beginning,but when i add startMyOwnForeground and Runnable,it doesn't work. Runnable is to connect to my datebase every 2 seconds to check if there is new message,and it will push notification to the user This is