1.拼接参数,可以借用BasicNameValuePair这么拼接
List<BasicNameValuePair> args = new ArrayList<BasicNameValuePair>();
args.add(new BasicNameValuePair("param"
, "[{\"id\":\"课程详情\",\"uid\":10086,\"name\":\"liqz\",\"time\":100,\"startTime\":141455757,\"oid\":1400}]"));
H.doPost("http://rcp.dev.jxzy.com/save-trlog", args, new HCallback.HCacheCallback(){
@Override
public void onError(CBase c, String cache, Throwable err)
throws Exception {
Log.i("result", "fail");
}
@Override
public void onSuccess(CBase c, HResp res, String data) throws Exception {
Log.i("result", "success"+data);
}
});
2.利用Timer TimerTask实现定时循环任务
public static void doUploadDataTask(final String url, final long delay, final long frequency) {
final Timer mTimer = new Timer();
final TimerTask mTimerTask = new TimerTask() {
@Override
public void run() {
UploadLearnData.uploadLearnData(url);
}
};
//这里为了保证在该方法只被调用一次的前提下 独立于主线程执行异步任务
new Thread(new Runnable() {
@Override
public void run() {
mTimer.schedule(mTimerTask, delay, frequency);
}
}).start();
}
- [利用ScheduledThreadPoolExecutor定时执行任务],点击链接进入:(http://blog.csdn.net/kazeik/article/details/8545049)