GithubHelp home page GithubHelp logo

zmywly8866 / phonenumber Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xdtianyu/phonenumber

2.0 2.0 0.0 1.17 MB

一个获取号码归属地和其他信息(诈骗、*扰等)的开源库

License: Apache License 2.0

Java 100.00%

phonenumber's Introduction

PhoneNumber

一个获取号码归属地和其他信息(诈骗、*扰等)的开源库。支持本地离线(含归属地、*扰、常用号码)和网络(百度、聚合数据或自定义 API)查询。English

Android Arsenal Build Status JAR Download

下载

通过 gradle 下载

dependencies {
    compile 'org.xdty.phone.number:phone-number:0.5.0'
}

或 maven

<dependency>
  <groupId>org.xdty.phone.number</groupId>
  <artifactId>phone-number</artifactId>
  <version>0.5.0</version>
  <type>aar</type>
</dependency>

或从 maven central 直接下载 AAR 文件

用法

1. 添加 meta-dataAndroidManifest

<meta-data
    android:name="org.xdty.phone.number.API_KEY"
    android:value="API_KEY"/>
<meta-data
    android:name="org.xdty.phone.number.JUHE_API_KEY"
    android:value="JUHE_API_KEY"/>

你可以从 百度 API 中心 获取 API_KEY , 从 聚合数据 (360) 获取 JUHE_API_KEY。这一部分是用于联网查询的 API 私钥。

也可以在代码中设置 baidu_api_keyjuhe_api_keySharedPreferences 来动态控制 API 密钥,更多内容请参考 来电信息 的实现。

2. 代码中添加如下内容, 更多内容请参考 exampleCallerInfo

new PhoneNumber(this, new PhoneNumber.Callback() {
    @Override
    public void onResponseOffline(INumber number) {
    }
    
    @Override
    public void onResponse(INumber number) {
        // Do your jobs here
        textView.setText(number.getName());
    }

    @Override
    public void onResponseFailed(INumber number) {
    }
}).fetch("10086", "10000", "10001", "OTHER_PHONE_NUMBER");

本地查询会通过 onResponseOffline(INumber number) 返回,联网查询会通过 onResponse(INumber number) 返回。

3. 自定义服务器及 API

请参考 自定义 API 文档

4. 自定义号码处理器

请参考 model 中的实现,实现 INumberNumberHandler 接口。并在调用 fetch 前调用 addNumberHandler(new YourCustomNumberHandler())

5. 禁用联网查询

请设置 only_offline_keySharedPreferences 来全局控制,或使用 PhoneNumber(context, true, callback) 临时控制。

6. 优先查询控制

默认的查询顺序为 本地特殊号码->本地常用号码->本地标记号码->本地离线归属地->Google离线归属地->联网自定义 API->联网百度 API->联网聚合数据(360) API 。可以通过设置 api_typeSharedPreferences 来控制优先的网络查询接口,值为每个模块的 getApiId() 返回值。

phonenumber's People

Contributors

xdtianyu avatar ravidsrk avatar

Stargazers

ycchen avatar 投木报琼 avatar

Watchers

James Cloos avatar Zhang Mingyun avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.