- 浏览: 26446 次
- 性别:
- 来自: 武汉
最新评论
文章列表
package com.cnki.client.utils;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.HashMap;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Environm ...
package com.cnki.client.utils;
import org.apache.http.Header;
import org.apache.http.client.CookieStore;
import org.apache.http.message.BasicHeader;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.net.wifi.WifiManager;
/**
* http请求的 ...
package com.cnki.client.utils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java. ...
package com.cnki.client.utils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
...
Android 应用自动更新代码
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.Htt ...
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
public class Address extends Activity {
private static final String TAG="App";
ListView listView;
ListAdapter ad ...
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.URL;
public class DownLoader {
//多线程文件下载
//使用HTTP的Range字段指定每条线程从文件的什么位置开始下载,如从文件的2mb位置下载就是bytes=2097252,2MB的字节
public static void main(String[] args){
//主方法
DownLoa ...
需要用到的权限
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permi ...
获取ip地址
1.使用WIFI
首先设置用户权限
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permiss ...
java代码
public class MainActivity extends Activity {
private static final String[] cities={"北京","上海","武汉","广州","深圳"};
private EditText name,age,pass;
private Button regButton;
private RadioGroup sexRadioGroup;
private CheckBox bask ...
获取网络信息需要在AndroidManifest.xml文件中加入相应的权限。
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
判断是否有网络连接
public boolean isNetworkConnected(Context context) {
if (context != null) {
ConnectivityManager mConnectivityManager = (ConnectivityManager) conte ...
需要用到的权限
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>//判断当前网络是否可用
public boolean note_Intent(Context context) {
ConnectivityManager con = (ConnectivityManager) context ...
private static final String LOG_TAG = "DeviceInfoSettings";
private static final String FILENAME_PROC_VERSION = "/proc/version";
private String readLine(String filename) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(filename), 256);
try ...
long exitTime=0;
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if(keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN){
if((System.currentTimeMillis()-exitTime) > 2000){
Toast.makeText(getApplicati ...
public class ShortcutUtil {
public static void createShortCut(Activity act, int iconResId,
int appnameResId) {
// com.android.launcher.permission.INSTALL_SHORTCUT
Intent shortcutintent = new Intent(
"com.android.launch ...