Skip to content

flying-pigeon 是一个IPC 跨进程通信组件,底层是匿名内存+Binder , 突破1MB大小限制,无需写AIDL文件,让实现跨进程通信就像写一个接口一样简单

License

Notifications You must be signed in to change notification settings

Justson/flying-pigeon

Repository files navigation

Flying-Pigeon

Flying-Pigeon 是一个IPC跨进程通信组件,把跨进程通信简化到极致,并且突破binder 1MB内存大小限制。

引入

  • Gradle
implementation 'com.github.Justson:flying-pigeon:v1.0.7'

方式一

Server

private Api mApi = new Api() {
        @Override
        public int createPoster(Poster poster) {
            Log.e(TAG, "poster:" + GsonUtils.toJson(poster));
            return 11;
        }
    };

对外发布服务

ServiceManager.getInstance().publish(mApi);

Client

final Pigeon pigeon = Pigeon.newBuilder(this).setAuthority(ServiceApiImpl.class).build();
Api api = pigeon.create(Api.class);
api.createPoster(new Poster("Justson", "just", 119, 11111000L, (short) 23, 1.15646F, 'h', (byte) 4, 123456.415D));

方式二

Server

@MainThread
@route("/query/username")
public void queryUsername(final Bundle in, final Bundle out) {
    ipcLabel.setText("received other app message,\n message:" + in.getString("userid"));
    out.putString("username", "ipc-sample");
}

对外发布服务

ServiceManager.getInstance().publish(this);

Client

Pigeon flyPigeon = Pigeon.newBuilder(MainActivity.this).setAuthority("com.flyingpigeon.ipc_sample").build();
Bundle bundle = flyPigeon.route("/query/username").withString("userid", UUID.randomUUID().toString()).fly();

混淆

-keep class com.flyingpigeon.library.*
-dontwarn com.flyingpigeon.library.*

建议

  • 建议App内使用方式一,App与其他App通信使用方式二
  • 返回的类型中,尽可能使用基本数据类型的包装类、如Integer,Double,Long,Short,Float,Byte,Boolean,Character

About

flying-pigeon 是一个IPC 跨进程通信组件,底层是匿名内存+Binder , 突破1MB大小限制,无需写AIDL文件,让实现跨进程通信就像写一个接口一样简单

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages