Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #155: Dumb terminal


comp / comp.mobile.android / telephonyManager.registerTelephonyCallback problem android 31 and above

SubjectAuthor
o telephonyManager.registerTelephonyCallback problem android 31 and aboveJakub

1
Subject: telephonyManager.registerTelephonyCallback problem android 31 and above
From: Jakub
Newsgroups: comp.mobile.android
Organization: http://www.wit.edu.pl
Date: Sat, 7 Sep 2024 07:39 UTC
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!news.icm.edu.pl!wsisiz.edu.pl!.POSTED.public-gprs411360.centertel.pl!not-for-mail
From: jak74@interia.pl (Jakub)
Newsgroups: comp.mobile.android
Subject: telephonyManager.registerTelephonyCallback problem android 31 and
above
Date: Sat, 7 Sep 2024 09:39:02 +0200
Organization: http://www.wit.edu.pl
Message-ID: <vbgvrm$2m6hn$1@portraits.wsisiz.edu.pl>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 7 Sep 2024 07:37:27 -0000 (UTC)
Injection-Info: portraits.wsisiz.edu.pl; posting-host="public-gprs411360.centertel.pl:37.47.238.33";
logging-data="2824759"; mail-complaints-to="abuse@wsisiz.edu.pl"
User-Agent: Mozilla Thunderbird
Content-Language: pl
View all headers

I have this variable at mainActiity

private lateinit var telephonyManager: TelephonyManager

and this fun

fun initTelephonyManager06() {
Log.i("ppp", "fun initTelephonyManager06() {")

telephonyManager =
getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager

if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.S ) {
Log.i("ppp", "if (Build.VERSION.SDK_INT >=
Build.VERSION_CODES.S) {")
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.READ_PHONE_STATE)
== PackageManager.PERMISSION_GRANTED ) {

telephonyManager.registerTelephonyCallback(
mainExecutor,
object : TelephonyCallback(),
TelephonyCallback.CallStateListener {
override fun onCallStateChanged(state: Int) {
Log.i("ppp", "override fun
onCallStateChanged(state: Int) {")
// Handle call state change
when (state) {
TelephonyManager.CALL_STATE_IDLE -> {
Log.i("ppp", "State changed: " +
state + " Idle")
}

TelephonyManager.CALL_STATE_OFFHOOK -> {
Log.i("ppp", "State changed: " +
state + " Offhook")
}

TelephonyManager.CALL_STATE_RINGING -> {
Log.i("ppp", "State changed: " +
state + " Ringing")
}

else -> {}
}
}
})
}
} else {
Log.i("ppp", "if (Build.VERSION.SDK_INT <
Build.VERSION_CODES.S) {")
telephonyManager.listen(object : PhoneStateListener() {
override fun onCallStateChanged(state: Int,
phoneNumber: String?) {
// Handle call state change
when ( state ) {
TelephonyManager.CALL_STATE_IDLE -> {
Log.i("ppp", "State changed: " + state + "
Idle")
}

TelephonyManager.CALL_STATE_OFFHOOK -> {
Log.i("ppp", "State changed: " + state + "
Offhook")
}

TelephonyManager.CALL_STATE_RINGING -> {
Log.i("ppp","State changed: " + state + "
Ringing")
}

else -> {}
}
}
}, PhoneStateListener.LISTEN_CALL_STATE)
}

}

and in androidmanifest.xml this permision

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

under android 31 S it work ok. Show every state.

But android upper or equal 31 don't show the state.

How to fix it? What to do?

1

rocksolid light 0.9.8
clearnet tor