I am making an App that should be able to detect call state, earlier I was advised to use PreciseCallState
since by default android cannot detect exactly what state the call is in, PreciseCallState
is in the Telephony Extension, which is in the android_frameworks_base, how to I get my Imports to work?, and for the most part will this work on Android < 5 or its only 5>?

- 25,161
- 11
- 89
- 121

- 217
- 1
- 3
- 14
2 Answers
What you need is the "Android Hidden/Internal SDK" (or "API"), as it's called on the Internet. Search Google for that, it will answer some questions you might have (which I no longer remember too much). A place to get started immediately with it would be this: https://github.com/anggrayudi/android-hidden-api. Have fun messing with the internal SDK!
By the way, just a note. Google blocked the internal APIs from Android Pie onwards: https://developer.android.com/guide/app-compatibility/restrictions-non-sdk-interfaces. There are also ways to get past those anyway xD: https://stackoverflow.com/a/55970138/8228163 (or search for "bypass android hidden/internal sdk limitations").
Or you could also go with reflection and not use the internal SDK at all. Though, I still prefer the SDK. When I update the SDK, if some class/method/constant is no longer on it, Android Studio will throw a compilation error and I will know I must go find a replacement immediately - won't happen with reflection. (Aside from having the documentation right there and just calling a function instead of trying magic with hidden functions and try/catch things which I don't like too much in these cases.)
("Internal" because of android.internal.*, and "Hidden" because of the "@hide" attribute on classes/methods/constants.)

- 447
- 1
- 6
- 23
But the permission is defined for special-use applications such as dialers, carrier applications, or ims applications. So how should ordinary applications handle it.
READ_PRECISE_PHONE_STATE public static final String READ_PRECISE_PHONE_STATE Allows read only access to precise phone state. Allows reading of detailed information about phone state for special-use applications such as dialers, carrier applications, or ims applications.
Constant Value: "android.permission.READ_PRECISE_PHONE_STATE"
-
This is a comment and not an definitive answer. Please keep comments to the post itself. – yams Feb 07 '22 at 17:43