Sticky broadcast giving security exception in Android for work in Android P

476 views Asked by At

I am using sticky broadcast in my application and I have included the following permission in my manifest.

uses-permission android:name="android.permission.BROADCAST_STICKY"

The app is working absolutely fine when installed normally in personal profile. The same app when installed only in work profile crashes because of security exception. If the app is installed in both work profile and personal profile then it works fine in both profiles.

  • Only Personal Profile : Works fine
  • Personal Profile & Work Profile : Works fine
  • Only Work Profile: Crash

The crash only happens in Android Pie.

The API which give exception is context.removeStickyBroadcast()

AndroidRuntime: Caused by: java.lang.SecurityException: Permission Denial: unbroadcastIntent() from pid=4015, uid=1010232 requires android.permission.BROADCAST_STICKY
10-10 22:22:32.900  4015  4015 E AndroidRuntime:    at android.os.Parcel.createException(Parcel.java:1942)
10-10 22:22:32.900  4015  4015 E AndroidRuntime:    at android.os.Parcel.readException(Parcel.java:1910)
10-10 22:22:32.900  4015  4015 E AndroidRuntime:    at android.os.Parcel.readException(Parcel.java:1860)
10-10 22:22:32.900  4015  4015 E AndroidRuntime:    at android.app.IActivityManager$Stub$Proxy.unbroadcastIntent(IActivityManager.java:3919)
10-10 22:22:32.900  4015  4015 E AndroidRuntime:    at android.app.ContextImpl.removeStickyBroadcast(ContextImpl.java:1346)
10-10 22:22:32.900  4015  4015 E AndroidRuntime:    at android.content.ContextWrapper.removeStickyBroadcast(ContextWrapper.java:588)
0

There are 0 answers