-
Notifications
You must be signed in to change notification settings - Fork 0
JAVA
StormKid edited this page Sep 9, 2019
·
3 revisions
新增java api
初始化:
public class JavaApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Okkt4j.getInstance().setBase("https://api.isoyu.com/api/").setNetClientType(Okkt4j.HTTPS_TYPE).isLogShow(true).setTimeOut(10000L).initHttpClient();
}
}
使用:
public class JavaActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
HashMap<String, String> map = new HashMap<>();
map.put("name", "广东省_深圳市");
map.put("page", "0");
Okkt4j.getInstance().getBuilder().setUrl("News/local_news").setParams(map).get(new CallbackRule<TestEntity>() {
@Override
public void onSuccess(TestEntity testEntity, String flag) {
Log.INSTANCE.d(testEntity.getMsg());
}
@Override
public void onFailed(String error) {
Log.INSTANCE.d(error);
}
});
}
}
其他方法同kt,请参考get post 请求内容。暂无下载文件,java 方法有内存泄漏嫌疑,现在查缺补漏中(目前可以使用API内部方法下载apk)