当前位置: 编程技术>移动开发
本页文章导读:
▪新浪微博API散文 新浪微博API杂记
1 获取指定用户的微博https://api.weibo.com/2/statuses/user_timeline.json参数uid false int64 需要查询的用户ID。feature false int 过滤类型ID,0:全部、1:原创、2:图片、3:视频、4:音乐.........
▪ 查看内存储器存储 查看内存存储
import java.io.File; import android.os.Environment; import android.os.StatFs; public class MemoryStatus { static final int ERROR = -1; static public boolean externalMemoryAvailable() { return android.os.Environment.getExternalSt.........
▪ handler处置message handler处理message
package com.lilin.handler;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.ImageView;
/**
* 通过Handler实现2秒自动换图
*
* @author.........
[1]新浪微博API散文
来源: 互联网 发布时间: 2014-02-18
新浪微博API杂记
1 获取指定用户的微博
https://api.weibo.com/2/statuses/user_timeline.json
参数
uid false int64 需要查询的用户ID。
feature false int 过滤类型ID,0:全部、1:原创、2:图片、3:视频、4:音乐,默认为0。
1 获取指定用户的微博
https://api.weibo.com/2/statuses/user_timeline.json
参数
uid false int64 需要查询的用户ID。
feature false int 过滤类型ID,0:全部、1:原创、2:图片、3:视频、4:音乐,默认为0。
[2] 查看内存储器存储
来源: 互联网 发布时间: 2014-02-18
查看内存存储
import java.io.File;
import android.os.Environment;
import android.os.StatFs;
public class MemoryStatus {
static final int ERROR = -1;
static public boolean externalMemoryAvailable() {
return android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
}
static public long getAvailableInternalMemorySize() {
File path = Environment.getDataDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
return availableBlocks * blockSize;
}
static public long getTotalInternalMemorySize() {
File path = Environment.getDataDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long totalBlocks = stat.getBlockCount();
return totalBlocks * blockSize;
}
static public long getAvailableExternalMemorySize() {
if(externalMemoryAvailable()) {
File path = Environment.getExternalStorageDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
return availableBlocks * blockSize;
} else {
return ERROR;
}
}
static public long getTotalExternalMemorySize() {
if(externalMemoryAvailable()) {
File path = Environment.getExternalStorageDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long totalBlocks = stat.getBlockCount();
return totalBlocks * blockSize;
} else {
return ERROR;
}
}
static public String formatSize(long size) {
String suffix = null;
if (size >= 1024) {
suffix = "KiB";
size /= 1024;
if (size >= 1024) {
suffix = "MiB";
size /= 1024;
}
}
StringBuilder resultBuffer = new StringBuilder(Long.toString(size));
int commaOffset = resultBuffer.length() - 3;
while (commaOffset > 0) {
resultBuffer.insert(commaOffset, ',');
commaOffset -= 3;
}
if (suffix != null)
resultBuffer.append(suffix);
return resultBuffer.toString();
}
}
import java.io.File;
import android.os.Environment;
import android.os.StatFs;
public class MemoryStatus {
static final int ERROR = -1;
static public boolean externalMemoryAvailable() {
return android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
}
static public long getAvailableInternalMemorySize() {
File path = Environment.getDataDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
return availableBlocks * blockSize;
}
static public long getTotalInternalMemorySize() {
File path = Environment.getDataDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long totalBlocks = stat.getBlockCount();
return totalBlocks * blockSize;
}
static public long getAvailableExternalMemorySize() {
if(externalMemoryAvailable()) {
File path = Environment.getExternalStorageDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
return availableBlocks * blockSize;
} else {
return ERROR;
}
}
static public long getTotalExternalMemorySize() {
if(externalMemoryAvailable()) {
File path = Environment.getExternalStorageDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long totalBlocks = stat.getBlockCount();
return totalBlocks * blockSize;
} else {
return ERROR;
}
}
static public String formatSize(long size) {
String suffix = null;
if (size >= 1024) {
suffix = "KiB";
size /= 1024;
if (size >= 1024) {
suffix = "MiB";
size /= 1024;
}
}
StringBuilder resultBuffer = new StringBuilder(Long.toString(size));
int commaOffset = resultBuffer.length() - 3;
while (commaOffset > 0) {
resultBuffer.insert(commaOffset, ',');
commaOffset -= 3;
}
if (suffix != null)
resultBuffer.append(suffix);
return resultBuffer.toString();
}
}
[3] handler处置message
来源: 互联网 发布时间: 2014-02-18
handler处理message
package com.lilin.handler; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.widget.ImageView; /** * 通过Handler实现2秒自动换图 * * @author lilin * @date 2011-8-10 上午08:51:27 * @ClassName: Main * @Description: TODO */ public class HandlerMessageDemo extends Activity { private ImageView myImageView;// ImageView的引用 private Handler myHandler = new Handler() {// 创建一个Handler对象 public void handleMessage(Message msg) {// 重写接收消息的方法 switch (msg.what) {// 判断what的值 case 0:// what值为0时 myImageView.setImageResource(R.drawable.bbta); break; case 1:// what值为1时 myImageView.setImageResource(R.drawable.bbtb); break; case 2:// what值为2时 myImageView.setImageResource(R.drawable.bbtc); break; case 3:// what值为3时 myImageView.setImageResource(R.drawable.bbtd); break; } super.handleMessage(msg); } }; public void onCreate(Bundle savedInstanceState) {// 重写的onCreate方法 super.onCreate(savedInstanceState); setTitle("handler通信:每2秒自动换图"); setContentView(R.layout.main);// 设置当前的用户界面 // Handler和Activity不属于同一线程,所以Hander实现了对消息的异步处理 String text = "当前activity的ID--->" + Thread.currentThread().getId(); System.out.println(text); text = "当前activity的名称--->" + Thread.currentThread().getName(); System.out.println(text); myImageView = (ImageView) findViewById(R.id.myImageView); new Thread() { public void run() { int i = 0; while (true) {// 循环 myHandler.sendEmptyMessage((i++) % 4);// 发送消息 String text = "handler的ID" + Thread.currentThread().getId(); System.out.println(text); text = "handler的名称" + Thread.currentThread().getName(); System.out.println(text); try { Thread.sleep(2000);// 注意这边加了延迟 } catch (Exception e) { e.printStackTrace(); } } }; }.start(); } }
最新技术文章: