Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void http3test()
- {
- SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(testActivity.this);
- String url = "http://" + appPreferences.getString(String.valueOf(R.string.prefer_share_sip_server), "192.168.1.101") + "/sip.cgi?action=showcalllog";
- okhttp3.OkHttpClient okHttpClient = new okhttp3.OkHttpClient();
- okhttp3.Request request = new okhttp3.Request.Builder()
- .url(url)
- .build();
- Call call = okHttpClient.newCall(request);
- call.enqueue(new okhttp3.Callback() {
- @Override
- public void onFailure(Call call, IOException e) {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- // Toast.makeText(testActivity.this,"Error",Toast.LENGTH_SHORT).show();
- Log.d("OKHTTP","Fail");
- String mTmp = String.format("連線超時,直接載入記憶體內容\n\n%s", mDebugTextView.getText().toString());
- mDebugTextView.setText(mTmp);
- SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(testActivity.this);
- String mStr = appPreferences.getString("tmp_ipphone_tel", "");
- Log.e("IP Phone", "建立List清單");
- Toast.makeText(testActivity.this,"連線超時",Toast.LENGTH_SHORT).show();
- InitList(mStr);
- }
- });
- }
- @Override
- public void onResponse(Call call, okhttp3.Response response) throws IOException {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- Toast.makeText(testActivity.this,"載入資料成功",Toast.LENGTH_SHORT).show();
- Log.d("OKHTTP","OK");
- }
- });
- String ret = response.body().string();
- response.body().close();
- ProcessHTML(ret);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement