https://github.com/justson/flying-pigeon
flying-pigeon 是一个IPC 跨进程通信组件,底层是匿名内存+Binder , 突破1MB大小限制,无需写AIDL文件,让实现跨进程通信就像写一个接口一样简单
https://github.com/justson/flying-pigeon
aidl android anonymous-memory binder contentprovider ipc service
Last synced: 3 months ago
JSON representation
flying-pigeon 是一个IPC 跨进程通信组件,底层是匿名内存+Binder , 突破1MB大小限制,无需写AIDL文件,让实现跨进程通信就像写一个接口一样简单
- Host: GitHub
- URL: https://github.com/justson/flying-pigeon
- Owner: Justson
- License: apache-2.0
- Created: 2020-06-11T10:34:28.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-09T06:29:33.000Z (over 4 years ago)
- Last Synced: 2025-03-16T11:11:21.223Z (3 months ago)
- Topics: aidl, android, anonymous-memory, binder, contentprovider, ipc, service
- Language: Java
- Homepage: https://github.com/Justson/flying-pigeon
- Size: 404 KB
- Stars: 211
- Watchers: 2
- Forks: 19
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Flying-Pigeon
Flying-Pigeon 是一个IPC跨进程通信组件,把跨进程通信简化到极致,并且突破binder 1MB内存大小限制。## 引入
* Gradle
```gradle
implementation 'com.github.Justson:flying-pigeon:v1.0.7'
```## 方式一
### Server
```java
private Api mApi = new Api() {
@Override
public int createPoster(Poster poster) {
Log.e(TAG, "poster:" + GsonUtils.toJson(poster));
return 11;
}
};
```#### 对外发布服务
```java
ServiceManager.getInstance().publish(mApi);
```### Client
``` java
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
```java
@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");
}
```
#### 对外发布服务
```java
ServiceManager.getInstance().publish(this);
```### Client
```java
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