Java 在React原生android中有没有办法检测最近的通话持续时间
我正在使用一个呼叫应用程序,我需要检测最近我刚刚打过的电话的呼叫持续时间。有什么软件包或方法可以做到这一点吗?没有特定的方法或库可以提供最近的电话通话持续时间,但您可以使用它来提供传入电话的侦听器,如Java 在React原生android中有没有办法检测最近的通话持续时间,java,android,react-native,phone-call,android-phone-call,Java,Android,React Native,Phone Call,Android Phone Call,我正在使用一个呼叫应用程序,我需要检测最近我刚刚打过的电话的呼叫持续时间。有什么软件包或方法可以做到这一点吗?没有特定的方法或库可以提供最近的电话通话持续时间,但您可以使用它来提供传入电话的侦听器,如 import CallDetectorManager from 'react-native-call-detection' startListenerTapped() { this.callDetector = new CallDetectorManager((event, phoneN
import CallDetectorManager from 'react-native-call-detection'
startListenerTapped() {
this.callDetector = new CallDetectorManager((event, phoneNumber)=> {
// For iOS event will be either "Connected",
// "Disconnected","Dialing" and "Incoming"
// For Android event will be either "Offhook",
// "Disconnected", "Incoming" or "Missed"
// phoneNumber should store caller/called number
if (event === 'Disconnected') {
// Do something call got disconnected
}
else if (event === 'Connected') {
// Do something call got connected
// This clause will only be executed for iOS
}
else if (event === 'Incoming') {
// Do something call got incoming
}
else if (event === 'Dialing') {
// Do something call got dialing
// This clause will only be executed for iOS
}
else if (event === 'Offhook') {
//Device call state: Off-hook.
// At least one call exists that is dialing,
// active, or on hold,
// and no calls are ringing or waiting.
// This clause will only be executed for Android
}
else if (event === 'Missed') {
// Do something call got missed
// This clause will only be executed for Android
}
},
false, // if you want to read the phone number of the incoming call [ANDROID], otherwise false
()=>{}, // callback if your permission got denied [ANDROID] [only if you want to read incoming number] default: console.error
{
title: 'Phone State Permission',
message: 'This app needs access to your phone state in order to react and/or to adapt to incoming calls.'
} // a custom permission request message to explain to your user, why you need the permission [recommended] - this is the default one
)
}
stopListenerTapped() {
this.callDetector && this.callDetector.dispose();
}
我已经试过了,但这并没有检测到是否有人接了电话。每种情况下都使用2种方法“摘机”和“断开连接”按顺序执行,但当有人拿起电话时,没有人执行