Home Article App接入BigBong

App接入BigBong

Release time:2018-07-09 10:03:40 Author:小键键 Reading volume:342

引用:

bigbang锤子官方版源码:https://github.com/SmartisanTech/packages_apps_BigBang

仿Smartisan OS 的 BigBang功能源码:https://github.com/baoyongzhang/BigBang


前言:大家都知道锤子的BigBong分词,锤子自己进行了开源,也已经有大神做出了整个项目,在整个开源项目的基础上,我提取处了其中的两个module,导入后,只需几句话就可以集成项目。


一、准备:module下载

蓝奏云下载地址:https://www.lanzous.com/i1dj0be 密码:4h8f

百度云下载地址:链接:https://pan.baidu.com/s/1yJpA0jK82AYQQHTE6WJ1Nw 密码:px0n

二、导入项目


主项目中:

compile project(':core')
compile project(':segment')
三、修改以下内容


core/AndroidManifest.xml(修改scheme

 <activity
            android:name=".BigBangActivity"
            android:excludeFromRecents="true"
            android:launchMode="singleTop"
            android:theme="@style/Theme.AppCompat.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>

                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>

                <data android:scheme="yjbigBang"/>


segment/src\main\java\com\baoyz\bigbang\segment\NetworkParser.java

  @Nullable
    private Request createRequest(String text) {
        String XToken="xxxxxxxxxx";//https://bosonnlp.com/注册获取密钥

        requestBody =RequestBody.create(MediaType.parse("application/json;charset=utf-8"), "[\""+text+"\"]");
        Request request = null;
        try {
            Request.Builder builder = new Request.Builder().url("http://api.bosonnlp.com/tag/analysis?space_mode=0&oov_level=3&t2s=0&&special_char_conv=0");
            builder.addHeader("Content-Type","application/json");  //将请求头以键值对形式添加,可添加多个请求头
            builder.addHeader("Accept","application/json");  //将请求头以键值对形式添加,可添加多个请求头
            builder.addHeader("X-Token",XToken);  //将请求头以键值对形式添加,可添加多个请求头

            request = builder.post(requestBody).build();
        } catch (Exception e) {
        }

        return request;
    }


四、主项目中:

 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("yjbigBang://?extra_text=" + URLEncoder.encode(text.toString(), "utf-8")));
                            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            startActivity(intent);

  
I want to comment

User comments


Comment time:2019-06-18 02:22:48

虽然看不懂但还是感觉很牛逼

Search

classification

Leave a message
http://blog.yujianweb.cn/index.php/
User login
You have not written any reviews yet!
You have commented!
Can only praise once!
You have a collection!