android-service

Foreground service getting killed from Oreo

别来无恙 提交于 2019-11-30 06:20:40
问题 I have written a foreground service which is working properly for all OS version lower than Oreo. From Oreo application process is getting killed after 5 minutes of closing and removing the application from recents. As per android developer documentation for background execution limitations OS should not kill application for which a foreground service is running and notification is shown in notification window. As per guidelines on developer documentation. I followed below steps to start

Exported service does not require permission: what does it mean?

不想你离开。 提交于 2019-11-30 06:12:57
问题 I created a service that is bound by other applications through AIDL, and I add it to the manifest as follows: <service android:name=".MyService"> <intent-filter> <action android:name="org.example.android.myservicedemo.IService" /> </intent-filter> </service> where IService is the AIDL interface. In this way, Eclipse show me the warning Exported service does not require permission . If I remove the intent-filter , the warning disappear, but obviously the applications are unable to bind to the

Using an AsyncTask inside a Service Class?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 05:32:55
问题 I have to upload data to a server. I am using a service that is running on the same process as my application. Should I use a Separate thread for upload process or Should I use a AsyncTask to upload data to server ? More specifically can I use AsyncTask inside a service class ? And should I use it ? This service should always be running in memory in order to send data to the server every 5 seconds. 回答1: Yes you can, the below code will run every 5 seconds. Use your regular connection code for

Service being killed while holding wake lock and after calling startForeground

允我心安 提交于 2019-11-30 05:29:39
I am having a problem where my service is being killed even though I am holding a wake lock and I have called startForeground . When this occurs the tablet (ASUS Transformer TF101), stops the service without calling onDestroy . There are no other apps visible, and log cat shows nothing out of the ordinary (no 'out of memory' message etc). Immediately after being killed, the service restarts. The app I am developing is a chat client and needs a constant connection, it is also plugin based, so my app is developed as such: Client - HostService - Multiple child 'Services'. The host service is

How to handle IPC between a service and an activity (and its subactivity)?

扶醉桌前 提交于 2019-11-30 05:20:12
问题 Communication between two different processes (a service and an activity) in Android can be managed via Messenger or AIDL: it is sufficient that an activity binds to a service. However, what happens if this activity has one or more sub-activity? From the moment when the main activity starts a sub-activity, I would like the communication to be redirected to the sub-activity; similarly, when the sub-activity is destroyed, I would like the communication is redirected back to the main activity,

Always show service in notification bar

此生再无相见时 提交于 2019-11-30 05:08:29
I want to add my app to the notification bar so that it always shows, like some apps in the Google Play store. I want it to be like this screen shot: I want my notification to not be cleared, and for my app to be opened when the notification is clicked. Here's My Service Class Code: package com.demo; import java.util.Random; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Intent; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.widget

Android Pie (9.0) WebView in multi-process

偶尔善良 提交于 2019-11-30 05:03:59
Starting Android Pie (API 28), Google isn't allowing using a single WebView instance in 2 different processes. Documentation: https://developer.android.com/reference/android/webkit/WebView.html#setDataDirectorySuffix(java.lang.String) As required, I called WebView.setDataDirectorySuffix("dir_name_no_separator") but unfortunately, I get an exception. I tried to call this method inside the 2nd process Service onCreate(). java.lang.RuntimeException: Unable to create service com.myapp.service.MyService: java.lang.IllegalStateException: Can't set data directory suffix: WebView already initialized

MediaPlayer Service Android

最后都变了- 提交于 2019-11-30 05:01:43
I am new to Android. I am creating service for Media Player so that it can continue to play song even if i close the application. I have created activity for Media Player and it is having all the functionality like play , pause , next , previous , seekbar and also includes oncompletionlistener . All works excellent. But Now i want that all should be managed by service. I have Created MyService Class : public class MyService extends Service { public static MediaPlayer mp; @Override public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null; } @Override public void

BroadcastReceiver or Messenger via Handler

我们两清 提交于 2019-11-30 04:56:01
I have an IntentService which need to pass a message to an Activity . I know two ways of doing so. use sendBroadcast() at the Service side while registering a broadcastReciever at the Activity side which will receiver the message. passing a Messenger to the Service side , which will point to a Handler at the Activity side, which will be ready to receive that message from the service. Which one is good for which purpose? Or both of them do the same? If your IntentService does not know whether the activity will exist (e.g., might have been destroyed), or if there are multiple activities that

What does android:enabled mean for a service?

你说的曾经没有我的故事 提交于 2019-11-30 04:45:18
问题 What does android:enabled mean for a service? The description says it's whether it can be instantiated by the system. What does that mean? Can it be used at all? Can it only be used locally? If you can use a "disabled" service in some way then how do you start it? If it can't be used at all then what in the world is the point? Can't you just comment out the service tag instead? I was looking into creating a service that isn't to be used by other applications. Not sure if adroid:enabled can be