如何在Android Pie(9.0)和9+中自动接听电话?

时间:2019-10-03 05:30:07

标签: java android

我一直在寻找如何通过代码自动接听电话的方法,并且我看到了许多相关文章和答案,例如Kitkat,棉花糖等较低版本,但是在奥利奥之后这似乎不起作用,有人可以帮助我找到方法吗?

我尝试使用Notification Services,因为android 7.0+使用通知 显示通话

public void onNotificationPosted(StatusBarNotification sbn) {
    try {
        if (sbn.getNotification().actions != null) {
            for (Notification.Action action : sbn.getNotification().actions) 
              {
                Log.e(TAG, "" + action.title);
                if (action.title.toString().equalsIgnoreCase("Answer")) {
                    Log.e(TAG, "" + true);
                    PendingIntent intent = action.actionIntent;

                    try {
                        intent.send();
                    } catch (PendingIntent.CanceledException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
      } catch (Exception e) {
          e.printStackTrace();
      }
 }

0 个答案:

没有答案