一旦ACTION_NEW_OUTGOING_CALL播出,我需要捕获对方回答的以下事件.您能否就如何实现这一目标提出建议?我知道有可能因为Android拨号器应用程序在他们拿起时激动地将绿色的android图标更改为该人的照片.谢谢!
更新:我已经看过Android上处理传出呼叫的应用程序的来源.我注意到以下方法ContactsUtils:
/**
* Kick off an intent to initiate a call.
*/
public static void initiateCall(Context context, CharSequence
phoneNumber) {
Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
Uri.fromParts("tel", phoneNumber.toString(), null));
context.startActivity(intent); }
Run Code Online (Sandbox Code Playgroud)
我想我的回答是在听的活动中Intent.ACTION_CALL_PRIVILEGED.所以重新回答我的问题:有谁知道哪个活动处理Intent.ACTION_CALL_PRIVILEGED?先谢谢你
我正在尝试在开始播放回铃音时检测拨出呼叫的状态.我已经尝试了各种方法来检测这种状态.这里是其中的一些:
PhoneStateListener:import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
public class CustomPhoneStateListener extends PhoneStateListener {
public void onCallStateChanged(int state, String num) {
Log.d(CallStatusPlugin.TAG, ">>>state changed" + state);
}
}
Run Code Online (Sandbox Code Playgroud)
但各国一样TelephonyManager.CALL_STATE_IDLE,TelephonyManager.CALL_STATE_OFFHOOK并没有给我们的国家.
READ_PRECISE_PHONE_STATE:将方法添加到上述相同的电话状态监听器
public void onPreciseCallStateChanged() {
Log.d(CallStatusPlugin.TAG, "onPreciseCallStateChanged");
}
Run Code Online (Sandbox Code Playgroud)
但根据我的研究,阅读精确状态需要应用程序必须是系统应用程序.
NotificationListener:public class CustomNotificationListener extends NotificationListenerService {
public static final String TAG = "CallStatusPlugin";
public CustomNotificationListener() {
Log.v(TAG, ">>> CustomNotificationListener");
}
public void onNotificationPosted(StatusBarNotification sbn) {
Log.i(TAG, "New …Run Code Online (Sandbox Code Playgroud) 该内部的Android类com.android.internal.telephony.Call包含一个名为国家和定义枚举如下:
public enum State {
IDLE, ACTIVE, HOLDING, DIALING, ALERTING, INCOMING, WAITING, DISCONNECTED, DISCONNECTING;
public boolean isAlive() {
return !(this == IDLE || this == DISCONNECTED || this == DISCONNECTING);
}
public boolean isRinging() {
return this == INCOMING || this == WAITING;
}
public boolean isDialing() {
return this == DIALING || this == ALERTING;
}
}
Run Code Online (Sandbox Code Playgroud)
不同的州代表什么?
我试图CallManager从com.android.internal.telephony包中访问类对象.
这是我的代码:
ClassLoader classLoader = TestActivity.class.getClassLoader();
final ClassLoader classLoader = this.getClass().getClassLoader();
try {
final Class<?> classCallManager =
classLoader.loadClass("com.android.internal.telephony.CallManager");
Log.i("TestActivity", classCallManager);
} catch (final ClassNotFoundException e) {
Log.e("TestActivity", e);
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,这是扔了一个ClassNotFoundException.同样的方法允许我访问PhoneFactory,但显然我不允许访问CallManager.
如果我能够上课,那么我想继续使用该课程,如下所示:
Method method_getInstance;
method_getInstance = classCallManager.getDeclaredMethod("getInstance");
method_getInstance.setAccessible(true);
Object callManagerInstance = method_getInstance.invoke(null);
Run Code Online (Sandbox Code Playgroud)
谁可以帮我这个事?
在此先感谢,
Harsha C.
我试图检测用户何时接听电话.我的应用程序拨打电话号码,但没有看到用户是否回答我无法执行我需要的关键功能.看起来你可以在第5版及以上版本中执行此操作,如本文所示,但我无法弄清楚如何做到这一点.我知道有人必须想出一个解决办法,因为正如一个人之前所说,一旦用户回答,呼叫计时器就会启动,所以必须有办法检测它.此问题已多次发布,但没有人发布正确答案.
似乎答案在于蒂姆S.答案在这里:
<uses-permission android:name="android.permission.READ_PRECISE_PHONE_STATE" />
<receiver android:name=".listener.OutCallLogger">
<intent-filter>
<action android:name="android.intent.action.PRECISE_CALL_STATE" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
public class OutCallLogger extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
switch (intent.getIntExtra(TelephonyManager.EXTRA_FOREGROUND_CALL_STATE, -2) {
case PreciseCallState.PRECISE_CALL_STATE_IDLE:
Log.d(This.LOG_TAG, "IDLE");
break;
case PreciseCallState.PRECISE_CALL_STATE_DIALING:
Log.d(This.LOG_TAG, "DIALING");
break;
case PreciseCallState.PRECISE_CALL_STATE_ALERTING:
Log.d(This.LOG_TAG, "ALERTING");
break;
case PreciseCallState.PRECISE_CALL_STATE_ACTIVE:
Log.d(This.LOG_TAG, "ACTIVE");
break;
}
}
}
Run Code Online (Sandbox Code Playgroud) 我是 android 初学者,正在开发一个 android 应用程序来监视用户通话时的网络状态(对于来电和去电)...
我可以通过实现 PhonestateListner 类并覆盖 onCallStateChanged 方法来监视网络状态。对于来电,我使用的是在 onCallStateChanged 方法内的 TelephonyManager 类中定义的常量(CALL_STATE_IDLE、CALL_STATE_OFFHOOK 和 CALL_STATE_RINGING),但这些常量无法正常工作对于拨出电话...
my question is
Run Code Online (Sandbox Code Playgroud)
请帮助我理解这个概念...感谢您的时间