随笔分类 - Android 为知笔记
从为知笔记移过来的
摘要:File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize; //分区大 小 long totalBlocks; //总分区 long
阅读全文
摘要:public class MD5Encoder { public static String encode(String string) throws Exception { byte[] hash = MessageDigest.getInstance("MD5").digest(string.g
阅读全文
摘要:
阅读全文
摘要:步骤1.添加custom_progress.xml文件: <?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDeg
阅读全文
摘要:try{ // 1.开启事务 db.beginTransaction(); 事务处理部分... //2.设置事务执行成功,提交时如果这行代码没有执行过,就会回滚 db.setTransactionSuccessful(); // 1.开启事务 db.beginTransaction(); 事务处理部
阅读全文
摘要://获取xml序列化器 XmlSerializer xs = Xml.newSerializer(); File file = new File("sdcard/sms2.xml"); FileOutputStream fos; try { fos = new FileOutputStream(fi
阅读全文
摘要://发送http请求 try { //1.使用网址构造一个URL对象 URL url = new URL(path); //2.获取连接对象 HttpURLConnection conn = (HttpURLConnection) url.openConnection(); //3.设置一些属性 /
阅读全文
摘要:Get请求时,请求参数直接拼接在url地址后面。 如:String path = "http://169.254.244.136/Web2/servlet/Login?name=" + URLEncoder.encode(name) + "&pass=" pass; //URLEncoder.enc
阅读全文
摘要:post请求时,请求参数写入输出流中,url地址除去拼接参数后的地址,如: "http://169.254.244.136/Web2/servlet/Login?name=" + URLEncoder.encode(name) + "&pass=" + pass; 正确地址: String path
阅读全文
摘要://1.创建client对象 HttpClient client = new DefaultHttpClient(); //2.创建get请求对象 HttpGet get = new HttpGet(path); //3.使用client发送get请求 HttpResponse response =
阅读全文
摘要://1.创建client对象 HttpClient client = new DefaultHttpClient(); //2.创建get请求对象 HttpGet get = new HttpGet(path); //3.使用client发送get请求 HttpResponse response =
阅读全文
摘要:package com.itheima.multithreaddownload; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStrea
阅读全文
摘要:第一步,创建一个广播接收者, CallReceiver extends BroadcastReceiver ; 第二步,在AndroidManifest.xml配置文件中注册广播接收者与配置监听电话拨号器发出的广播的Action: <receiver android:name="com.itheim
阅读全文
摘要:第一步,创建一个广播接收者, SmsReceiver extends BroadcastReceiver ; 第二步,在AndroidManifest.xml配置文件中注册广播接收者与配置监听电话拨号器发出的广播的Action: <receiver android:name="com.itheima
阅读全文
摘要:第一步,创建一个广播接收者, SDReceiver extends BroadcastReceiver ; 第二步,在AndroidManifest.xml配置文件中注册广播接收者与配置监SD卡状态发生变化时对应的Action: <receiver android:name="com.itheima
阅读全文
摘要:第一步,创建一个广播接收者, BootReceiver extends BroadcastReceiver 第二步,在AndroidManifest.xml配置文件中注册广播接收者与配置开机启动时对应的Action: <receiver android:name="com.itheima.lesuo
阅读全文
摘要:在MainActivity中 public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanc
阅读全文
摘要:第一步,创建一个广播接收者, AppsReceiver extends BroadcastReceiver 第二步,在AndroidManifest.xml配置文件中注册广播接收者与配置应用状态发生时对应的Action: <receiver android:name="com.itheima.app
阅读全文
摘要:public class RegisterService extends Service { private ScreenOnOFFReceiver receiver; @Override public IBinder onBind(Intent intent) { // TODO Auto-gen
阅读全文
摘要:> 图片大小 = 图片的总像素 * 每个像素占用的大小 * 单色图:每个像素占用1/8个字节 * 16色图:每个像素占用1/2个字节 * 256色图:每个像素占用1个字节 * 24位图:每个像素占用3个字节 #加载大图片到内存(掌握) >Android系统以ARGB表示每个像素,所以每个像素占用4个
阅读全文
浙公网安备 33010602011771号