比如判断通话界面的activity是否显示 ,直接上代码:
boolean result = false;
ActivityManager am = (ActivityManager) context
.getSystemService(Context.ACTIVITY_SERVICE);
ComponentName cn = am.getRunningTasks(2).get(0).topActivity;
if (cn != null) {
if ("com.android.phone.InCallScreen".equals(cn.getClassName())) {
result = true;
}
}
return result;
需要加入权限:
<uses-permission android:name="android.permission.GET_TASKS" />
本文介绍了一种通过获取当前运行的任务栈来判断Android系统中通话界面(InCallScreen Activity)是否显示的方法,并提供了具体的实现代码。该方法适用于需要监控通话状态的应用场景。
1795

被折叠的 条评论
为什么被折叠?



