“电话"功能如何应用程序显示不在通讯簿上的联系人信息吗? [英] How does "Phone" app show information of contacts that are not on the address book?

查看:113
本文介绍了“电话"功能如何应用程序显示不在通讯簿上的联系人信息吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

在"> Google的电话 "应用中,有一个选项来电显示和垃圾邮件":

因此,如果您收到了不在通讯录上的某个人或某个组织的呼叫,但是以某种方式被识别,您将为其命名,例如(称为"+ 972-035283487"):

从Android M(6.0-API 23)开始,应用程序可以替换默认的电话应用程序,然后通过扩展 此处 .

问题

我想尝试显示与电话"应用程序上相同的信息,这意味着个人/公司的名称,以防万一它(不在通讯录上)识别出来.

我尝试过的

我试图对通过拨号器的API获得的各种信息进行挖掘,但是失败了:

  1. 以下各项的各种字段和功能: android.telecom.Call

  2. getDetails 在Call类中,因此我尝试获取其中的内容,并且还有 statusHints ".这些都没有任何信息(返回null).我尝试查看"statusHints"的原因是因为这就是我在文档上看到的内容:

包含在通话界面中显示的状态标签和图标.

  1. 在电话"应用上,按了解更多"可访问网站(这里)的链接,我认为这些链接可能是数据的来源,但我不认为应用程序本身会使用此链接.相反,我认为它使用了Google的某些东西.

问题

  1. 是否可以获取此CallerId信息?如果是这样,怎么办?

  2. 电话"应用程序如何执行此操作?它应该是开源的,所以必须有一些东西可以提供此信息,对吗?克隆它会以某种方式获得此信息吗?也许Google拥有自己的CallerID服务?

  3. "callDetails"和"statusHints"分别用于什么?他们提供什么?

解决方案

我认为Android的本地电话应用程序正在使用Google的位置搜索API.由于您可以通过电话号码轻松搜索地点,并获取地点详细信息,例如名称,地点ID,formatted_address以及可以在 https://maps.googleapis.com/maps/api/place/findplacefromtext/json

请求方法:GET

请求查询参数:

  • 密钥:您应用程序的API密钥.
  • 输入:用于指定要搜索的位置(例如姓名或电话号码)的文本输入.
  • 输入类型:输入的类型.这可以是 文字查询或电话号码之一.电话号码必须在 国际格式(以加号("+")开头,后跟 国家/地区代码,然后是电话号码本身.

示例请求: https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=%2B972035283487&inputtype=phonenumber&fields=place_id,name&key=API_KEY_HERE

示例响应:

{
   "candidates" : [
      {
         "name" : "מלך העופות",
         "place_id" : "ChIJ78ko1zBKHRURpwbgUdWc4nU"
      },
      {
         "name" : "Of Yaakov",
         "place_id" : "ChIJv3myn4FMHRURUGffcXgxKuw"
      }
   ],
   "status" : "OK"
}

注意: 目前,此类API在Android的Google Places SDK中尚不可用,但是您可以直接在应用中使用HTTP API,也可以在后端制作一个API作为places API的代理.我更喜欢更高版本,因为在第一个解决方案中,API密钥已部署在应用程序代码中,黑客可能会反编译APK并出于恶意原因使用它.出于安全原因,如果使用后端解决方案,则必须将API密钥的使用限制为服务器的IP地址!

Background

In the "Phone" app of Google, there is an option "Caller ID & spam" :

So, if you get a call from someone or some organization that isn't on the address book, yet it is identified somehow, you get a name for it, as such (called "+972-035283487") :

Ever since Android M (6.0 - API 23) , apps can replace the default phone app, and then also providing alternative UI when you call someone or get a phone call, by extending InCallService class, as demonstrated here which is based on here.

The problem

I want to try to show the same information as on the Phone app, meaning the name of the person/company in case it identified it (and it's not on the address book).

What I've tried

I tried to dig over the various things that I get via the API of the dialer, but failed:

  1. Various fields and functions of: android.telecom.Call class

  2. There is getDetails inside of the Call class, so I tried to get what's inside there, and there is also statusHints and "label" inside the "statusHints" . None of those had any information (returned null). The reason I tried to look at "statusHints" is because that's what I see on the docs :

Contains status label and icon displayed in the in-call UI.

  1. On the "Phone" app, pressing "Learn more" goes to a website (here) full of links that I think might be sources of the data, but I don't think the app itself uses this. Instead I think it uses something of Google.

The questions

  1. Is it possible to get this CallerId information? If so, how?

  2. How does the Phone app do it? It's supposed to be open sourced, so there has to be something that gives it this information, right? Would cloning it somehow get this information? Maybe Google has its own service for CallerID?

  3. What are the "callDetails" and "statusHints" used for? What do they provide?

解决方案

I believe Android's native phone app is using Google's place search API. As you can easily search for a place by its phone number and get place details like name, place id, formatted_address and many other fields that you can find in the documentation

Request URL: https://maps.googleapis.com/maps/api/place/findplacefromtext/json

Request method: GET

Request query parameters:

  • key: Your application's API key.
  • input: The text input specifying which place to search for (for example a name or phone number).
  • inputtype: The type of input. This can be one of either textquery or phonenumber. Phone numbers must be in international format (prefixed by a plus sign ("+"), followed by the country code, then the phone number itself).

Example request: https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=%2B972035283487&inputtype=phonenumber&fields=place_id,name&key=API_KEY_HERE

Example response:

{
   "candidates" : [
      {
         "name" : "מלך העופות",
         "place_id" : "ChIJ78ko1zBKHRURpwbgUdWc4nU"
      },
      {
         "name" : "Of Yaakov",
         "place_id" : "ChIJv3myn4FMHRURUGffcXgxKuw"
      }
   ],
   "status" : "OK"
}

Note: Such an API is not available at the current moment in Google places SDK for Android, but you can use the HTTP API directly in your app or you can make an API in the backend as a proxy to the places API. I prefer the later version as in the first solution the API key is deployed in the application code and hackers could decompile the APK and use it for malicious reasons. For security reasons you have to restrict the usage of the API key to the IP address of the server in case you are using the backend solution!

这篇关于“电话"功能如何应用程序显示不在通讯簿上的联系人信息吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆