- 博客(24)
- 资源 (1)
- 收藏
- 关注
原创 Android AIDL接口定义语言
跨进程访问(AIDL服务) Android系统中的进程之间不能共享内存,因此,需要提供一些机制在不同进程之间进行数据通信。在4个Android应用程序组件中的3个(Activity、Broadcast和Content Provider)都可以进行跨进程访问,另外一个Android应用程序组件Service同样可以,也即AIDL服务。...
2011-11-23 17:51:29
171
原创 Android 广播机制
一听广播二字,我们第一感觉就会联想到了小时候村里的广播播音,收音机等。对于广播来说,广播发送方并不在意广播接收方动作,接收到广播时如何处理,需要干什么,那是你接受者事。其实,Android 中的广播又何尝不是呢。 Android 中有各式各样的广播,各种广播在Android 系统中运行,当系统/应用程序运行时便会向 Android 注册各种广播,Andro...
2011-11-21 17:48:12
140
原创 Android中的Parcel机制 实现Bundle传递对象
Android中的Parcel机制 实现了Bundle传递对象 使用Bundle传递对象,首先要将其序列化,但是,在Android中要使用这种传递对象的方式需要用到Android Parcel机制,即,Android实现的轻量级的高效的对象序列化和反序列化机制。 JAVA中的Serialize机制,译成串行化、序列化……,其作用是能将数据对象存入字节流当中,在需要时重...
2011-11-18 17:27:05
343
原创 Android 缩放图片
/** * resize Bitmap * * @param bitmap * @param newWidth * @return */public static Bitmap resizeBitmap(Bitmap bitmap, int newWidth) { if (bitmap == null) return null; int w = b...
2011-08-24 17:23:24
142
原创 Android 优化Bitmap避免OutOfMemoryError
使用android提供的BitmapFactory解码图片时,往往会因为图片过大而遇到OutOfMemoryError的异常。要想正常使用,一种简便的方式是分配更少的内存空间来存储,即在载入图片的时候以牺牲图片质量为代价,将图片进行放缩,这是一种避免OOM所采用的解决方法。但是,这种方法是得不偿失的,牺牲了图片质量。 在BitmapFactory中有一个内部类BitmapFactory.Opt...
2011-08-24 17:08:02
224
原创 Android 计算ImageView的大小
1.获取资源文件中图片的大小,最简单的最直接的方法,就是使用Drawable的getIntrinsicHeight()和getIntrinsicWidth();2.利用Bitmap来获取其大小,本质上和第一种方式没什么区别: /** * 计算ImageView的大小(BitmapDrawable) * * @param resources * @param resou...
2011-08-24 14:19:36
237
原创 Android Bitmap与byte[]之间的转换
1.Bitmap-->byte[]:public static byte[] Bitmap2Bytes(Bitmap bm) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.PNG, 100, baos); retur...
2011-08-23 22:04:20
1461
1
原创 Android Drawable转换为Bitmap
public static Bitmap drawableToBitmap(Drawable drawable) { try { Bitmap bitmap = Bitmap .createBitmap( drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), drawa...
2011-08-23 21:56:00
254
原创 Android Drawable、Bitmap、Canvas和Paint的区别
Android平台中的显示类是View,但是还提供了底层图形类android.graphics。 Bitmap - 称作位图,一般位图的文件格式后缀为bmp,当然编码器也有很多如RGB565、RGB8888。作为一种逐像素的显示对象执行效率高,但是缺点也很明显存储效率低。我们理解为一种存储对象比较好。 Drawable - 作为Android平下通用的图形对象,它可以装...
2011-08-23 21:53:04
116
原创 Android开发中用到的命令
Android开发中用到的命令一些命令,不常用就忘记了,特整理在这里,忘了就查查。。* 创建Android虚拟设备(AVD)android create avd -n –name –t –target(1、2、3)* ddms(其文件管理功能)* 创建sdcardmksdcard –l label <size> <sdFilePath>* 启动模...
2011-08-19 22:16:26
111
原创 Android基本组件
[转]Android基本组件Basic Components 1. Activity 2. Service 3. Broadcast Receiver 4. Content Provider 5. Intent Activity——应用表示层(基类Activity) ...
2011-08-19 22:14:53
136
原创 Android下基于XML的Graphics shape使用方法
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#FFFF0000" android:endColor="#80FF00FF" android:ang...
2011-08-19 22:09:59
114
原创 Android activity属性设置大全
activity属性设置大全android:allowTaskReparenting=["true" | "false"] 是否允许activity更换从属的任务,比如从短信息任务 切换到浏览器任务。android:alwaysRetainTaskState=["true" | "false"] 是否保留状态不变, 比如切换回home, 再从新打开, a...
2011-08-19 21:58:29
112
原创 android 消息提醒(Toast,Notification)
android 提醒(Toast,Notification)[Toast]1,显示提示信息public static Toast makeText (Context context, CharSequence text, int duration).show()public static Toast makeText (Context context, int resId, int...
2011-08-19 21:55:08
116
原创 Android AlertDialog去除白色边框
使用styles.xml风格: <style name="FullScreenDialog" parent="android:style/Theme.Dialog"> <item name="android:windowNoTitle">true</item> <item name="android:windowFrame
2011-08-12 13:33:47
340
原创 Android Spannable设置TextView样式
Spannable span = (Spannable) textView.getText();TextAppearanceSpan textappearancespan = new TextAppearanceSpan( mcontext, R.style.SynonyText);span.setSpan(textappearancespan, start, end, Spa...
2011-08-10 13:30:58
183
原创 判断字符串是否为英文
public static boolean isEnglish(String word) { boolean isEnglish = false; for (int i = 0; i < word.length(); i++) { if (word.charAt(i) >= 0x0000 && word.charAt(i) <= 0x00f...
2011-07-20 16:05:54
614
原创 判断字符串是否是中文
public static boolean isChinese(String word) { boolean isChinese = false; for (int i = 0; i < word.length(); i++) { if (word.charAt(i) >= 0x0391 && word.charAt(i) <= 0xffe...
2011-07-20 16:04:54
145
原创 以全角/半角划分字符串
public static final String HALFANDFULLHORNSYMBOLS = "[-,/,|,$,+,%,&,',(,),*," + "\\x20-\\x2f,\\x3a-\\x40,\\x5b-\\x60,\\x7b-\\x7e,\\x80-\\xff," + "\u3000-\u3002,\u300a,\u300b,\u300e-\u30...
2011-07-20 16:00:34
142
原创 格式化时间显示方式
private String stringFormatterTime(int timeMs) { int totalSeconds = timeMs / 1000; int s = totalSeconds % 60; int m = (totalSeconds / 60) % 60; int h = totalSeconds / 3600; StringBu...
2011-07-20 15:53:44
145
原创 Android 音频录音
检查SDcard是否存在: private boolean checkSDCard() { if (Environment.MEDIA_MOUNTED.equals(Environment .getExternalStorageState()) && Environment.getExternalStorageDirectory().canWrite()) {...
2011-07-19 14:40:05
108
原创 自定义Layout的基本框架
public class SimpleMenuView extends RelativeLayout implements OnClickListener { private Context mContext; public SimpleMenuView(Context context) { super(context); mContext = context;...
2011-06-29 16:09:54
156
原创 Android图片圆角处理
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap) { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = n...
2011-06-27 17:16:03
79
转载 Android图片圆角处理
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap) { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); final int color = 0xff424242; final Paint pai
2010-11-22 11:33:00
275
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人