Reputation: 435
I was following below tutorial to check copy text event while the app is background or closed.
Now It's not working when the app is closed in android oreo. Is there any alternate of ClipboardMonitorService as background service is removed after API 26.
Upvotes: 0
Views: 2841
Reputation: 11
JobScheduler is the best alternative. You can set a time interval of 15 minutes and it will re-schedule your job after every 15 minutes. I know this will not work like service but you can make use of it by optimizing it properly.
Upvotes: 0
Reputation: 4809
Ref to Broadcast receiver is not working in lollipop after application closed from task manager
Please see the following,
Android Broadcast receiver not executed on application close
I also think that you might want to read up on how to set the priority. Please read the following,
AndroidManifestIntentFilter_priority
int AndroidManifestIntentFilter_priority Specify the relative importance or ability in handling a particular Intent. For receivers, this controls the order in which they are executed to receive a broadcast (note that for asynchronous broadcasts, this order is ignored). For activities, this provides information about how good an activity is handling an Intent; when multiple activities match an intent and have different priorities, only those with the higher priority value will be considered a match.
Only use if you really need to impose some specific order in which the broadcasts are received, or want to forcibly place an activity to always be preferred over others. The value is a single integer, with higher numbers considered to be better.
Must be an integer value, such as "100".
This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.
This corresponds to the global attribute resource symbol priority.
Constant Value: 2 (0x00000002)
As suggested by various posts and blogs i tried using
- Intent.Flag_Include_Stopped_Packages
- receiver android:process=":remote" in manifest
- receiver android:exported="true" in manifest
In Manifest:
<receiver android:name=".BroadcastReceiver" android:enabled="true"
android:exported="true"
android:process=":remote">
</receiver>
And According to Android 8.0 Behavior Changes
Background execution limits
As one of the changes that Android 8.0 (API level 26) introduces to improve battery life, when your app enters the cached state, with no active components, the system releases any wakelocks that the app holds.
In addition, to improve device performance, the system limits certain behaviors by apps that are not running in the foreground. Specifically:
Android 8.0 (API level 26) also includes the following changes to specific methods:
For more information, see Background Execution Limits.
Interface to the clipboard service, for placing and retrieving text in the global clipboard.
The ClipboardManager API itself is very simple: it consists of methods to atomically get and set the current primary clipboard data. That data is expressed as a ClipData object, which defines the protocol for data exchange between applications.
For More Info Please Visit Once https://developer.android.com/reference/android/content/ClipboardManager
Upvotes: 0
Reputation: 1789
As part of Android Oreo, there were several restrictions placed on background services. I don't think your problem can be solved. Please refer this post to know more. All the different types of execution models are explained in that post. I know I wasn't much help, but I figured i'll share what I know.
Upvotes: 1