@@ -0,0 +1,1639 @@
+package com.littlepanpc.downloader.util;%0A%0Aimport java.util.UUID;%0A%0Aimport android.content.Context;%0Aimport android.net.ConnectivityManager;%0Aimport android.net.NetworkInfo;%0A%0Apublic class NetworkUtils %7B%0A%09private static final String TAG = NetworkUtils.class.getSimpleName();%0A%09%0A%09public static boolean isNetworkAvailable(Context context) %7B%0A%09%09LogUtils.i(TAG, %22isNetworkAvailable--- start%22);%0A%09%09ConnectivityManager connectivity = (ConnectivityManager) context%0A%09%09%09%09.getSystemService(Context.CONNECTIVITY_SERVICE);%0A%09%09if (connectivity == null) %7B%0A%09%09%09LogUtils.i(TAG, %22isNetworkAvailable---1%22);%0A%09%09%09return false;%0A%09%09%7D else %7B%0A%09%09%09LogUtils.i(TAG, %22isNetworkAvailable---2%22);%0A%09%09%09NetworkInfo%5B%5D info = connectivity.getAllNetworkInfo();%0A%09%09%09LogUtils.i(TAG, %22isNetworkAvailable---3%22);%0A%09%09%09if (info != null) %7B%0A%09%09%09%09LogUtils.i(TAG, %22isNetworkAvailable---4%22);%0A%09%09%09%09for (int i = 0; i %3C info.length; i++) %7B%0A%09%09%09%09%09LogUtils.i(TAG, %22isNetworkAvailable---5%22);%0A%09%09%09%09%09if (info%5Bi%5D.getState() == NetworkInfo.State.CONNECTED%0A%09%09%09%09%09%09%09%7C%7C info%5Bi%5D.getState() == NetworkInfo.State.CONNECTING) %7B%0A%09%09%09%09%09%09LogUtils.i(TAG, %22isNetworkAvailable---true%22);%0A%09%09%09%09%09%09return true;%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%09LogUtils.i(TAG, %22isNetworkAvailable---end%22);%0A%09%09return false;%0A%09%7D%0A%09%0A%09public static String getFileNameFromUrl(String url) %7B%0A%09%09// %E9%80%9A%E8%BF%87 %E2%80%98%EF%BC%9F%E2%80%99 %E5%92%8C %E2%80%98/%E2%80%99 %E5%88%A4%E6%96%AD%E6%96%87%E4%BB%B6%E5%90%8D%0A%09%09int index = url.lastIndexOf('?');%0A%09%09String filename;%0A%09%09if (index %3E 1) %7B%0A%09%09%09filename = url.substring(url.lastIndexOf('/') + 1, index);%0A%09%09%7D else %7B%0A%09%09%09filename = url.substring(url.lastIndexOf('/') + 1);%0A%09%09%7D%0A%0A%09%09if (filename == null %7C%7C %22%22.equals(filename.trim())) %7B// %E5%A6%82%E6%9E%9C%E8%8E%B7%E5%8F%96%E4%B8%8D%E5%88%B0%E6%96%87%E4%BB%B6%E5%90%8D%E7%A7%B0%0A%09%09%09filename = UUID.randomUUID() + %22.apk%22;// %E9%BB%98%E8%AE%A4%E5%8F%96%E4%B8%80%E4%B8%AA%E6%96%87%E4%BB%B6%E5%90%8D%0A%09%09%7D%0A%09%09return filename;%0A%09%7D%0A%7D%0A

Create NetworkUtils.java