| | |
| | | package cn.com.basic.face.service;
|
| | |
|
| | | import android.app.ActivityManager;
|
| | | import android.content.Context;
|
| | | import android.net.ConnectivityManager;
|
| | | import android.net.NetworkInfo;
|
| | | import android.text.format.Formatter;
|
| | |
|
| | | import java.io.BufferedInputStream;
|
| | | import java.io.BufferedReader;
|
| | |
| | | import java.io.InputStreamReader;
|
| | | import java.net.URL;
|
| | | import java.net.URLConnection;
|
| | | import java.util.List;
|
| | |
|
| | | import cn.com.basic.face.base.BaseApplication;
|
| | | import cn.com.basic.face.base.MainActivity;
|
| | |
| | | } else {
|
| | | MainActivity.getInstance().setInternetAccessible(CommonVariables.InternetAccess.INTERNET_NOT_ACCESSIBLE);
|
| | | }
|
| | |
|
| | |
|
| | | // ActivityManager activityManager = (ActivityManager)MainActivity.getInstance().getSystemService(Context.ACTIVITY_SERVICE);
|
| | | // List<ActivityManager.RunningAppProcessInfo> runningAppProcessInfos = activityManager.getRunningAppProcesses();
|
| | | // int size = runningAppProcessInfos.size();
|
| | | //
|
| | | // ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
|
| | | //
|
| | | // activityManager.getMemoryInfo(memoryInfo);
|
| | | //
|
| | | // long availMem = memoryInfo.availMem;
|
| | | //
|
| | | // long totalMem = memoryInfo.totalMem;
|
| | | //
|
| | | // System.out.println("availMem="+Formatter.formatFileSize(MainActivity.getInstance(), availMem)+",totalMem="+
|
| | | // Formatter.formatFileSize(MainActivity.getInstance(), totalMem));
|
| | |
|
| | |
|
| | |
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
| | |
|
| | |
|
| | | public static boolean openUrl() {
|
| | | StringBuilder total = new StringBuilder();
|
| | | StringBuilder javaServerResponse = new StringBuilder();
|
| | | try {
|
| | | URL url = new URL(AppApi.BASE_URL);
|
| | | URLConnection urlCon = url.openConnection();
|
| | |
| | |
|
| | | String line;
|
| | | while ((line = bufferedReader.readLine()) != null) {
|
| | | total.append(line).append('\n');
|
| | | javaServerResponse.append(line).append('\n');
|
| | | }
|
| | | bufferedReader.close();
|
| | | bis.close();
|
| | | is.close();
|
| | | } catch (Exception e) {
|
| | | //e.printStackTrace();
|
| | | System.out.println(e.getMessage());
|
| | | return false;
|
| | | }
|
| | |
|
| | | if (total.toString().indexOf("Hello World!") > -1) {
|
| | | // StringBuilder cPlusPlusServerResponse = new StringBuilder();
|
| | | // try {
|
| | | // URL url = new URL("http://60.205.222.4:8080");
|
| | | // URLConnection urlCon = url.openConnection();
|
| | | // urlCon.setConnectTimeout(1500);
|
| | | // InputStream is = urlCon.getInputStream();
|
| | | // BufferedInputStream bis = new BufferedInputStream(is);
|
| | | //
|
| | | // BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(bis));
|
| | | //
|
| | | // String line;
|
| | | // while ((line = bufferedReader.readLine()) != null) {
|
| | | // cPlusPlusServerResponse.append(line).append('\n');
|
| | | // }
|
| | | // bufferedReader.close();
|
| | | // bis.close();
|
| | | // is.close();
|
| | | // } catch (Exception e) {
|
| | | // return false;
|
| | | // }
|
| | | // if (cPlusPlusServerResponse.indexOf("ip") < 0) {
|
| | | // return false;
|
| | | // }
|
| | | if (javaServerResponse.toString().indexOf("Hello World!") > -1) {
|
| | | return true;
|
| | | } else {
|
| | | return false;
|