`
chjmars
  • 浏览: 76058 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论
文章列表
跨进程访问(AIDL服务)         Android系统中的进程之间不能共 享内存,因此,需要提供一些机制在不同进程之间进行数据通信。在4个Android应用程序组件中的3个(Activity、Broadcast和 Content Provider)都可以进行跨进程访问,另外一个Android应用程序组件Service同样可以,也即AIDL服务。 什么是AIDL服务     为了使其他的应用程序也可以访问本应用程序提供的服务,Android系统采用了远程过程调用(Remote Procedure Call,R ...
    一听广播二字,我们第一感觉就会联想到了小时候村里的广播播音,收音机等。对于广播来说,广播发送方 并不在意广播接收方 动作, 接收到广播时如何处理,需要干什么,那是你接受者事。其实,Android 中的广播又何尝不是呢。     Android 中有各式各样的广播,各种广播在Android 系统中运行,当系统/应用程序运行时便会向 Android 注册各种广播,Android 接收到广播会便会判断哪种广播需要哪种事件,然后向不同需要事件的应用程序注册事件,不同的广播可能处理不同的事件也可能处理相同的广播事件,这时就需要 Android 系统为我们做筛选。 ...
Android中的Parcel机制     实现了Bundle传递对象     使用Bundle传递对象,首先要将其序列化,但是,在Android中要使用这种传递对象的方式需要用到Android Parcel机制,即,Android实现的轻量级的高效的对象序列化和反序列化机制。     JAVA中的Serialize机制,译成串行化、序列化……,其作用是能将数据对象存入字节流当中,在需要时重新生成对象。主要应用是利用外部存储设备保存对象状态,以及通过网络传输对象等。         Android中的新的序列化机制         在Android系统中,定位为针对内存受限的设备, ...
/** * resize Bitmap * * @param bitmap * @param newWidth * @return */ public static Bitmap resizeBitmap(Bitmap bitmap, int newWidth) { if (bitmap == null) return null; int w = bitmap.getWidth(); int h = bitmap.getHeight(); Log.e("Jarvis", w + "~" + h); ...
使用android提供的BitmapFactory解码图片时,往往会因为图片过大而遇到OutOfMemoryError的异常。要想正常使用,一种简便的方式是分配更少的内存空间来存储,即在载入图片的时候以牺牲图片质量为代价,将图片进行放缩,这是一种避免OOM所采用的解决方法。但是,这种方法是得不偿失的,牺牲了图片质量。 在BitmapFactory中有一个内部类BitmapFactory.Options,其中值得我们注意的是inSampleSize和inJustDecodeBounds两个属性:
1.获取资源文件中图片的大小,最简单的最直接的方法,就是使用Drawable的getIntrinsicHeight()和getIntrinsicWidth(); 2.利用Bitmap来获取其大小,本质上和第一种方式没什么区别:   /** * 计算ImageView的大小(BitmapDrawable) * * @param resources * @param resourceId * @return */ public static int[] computeWH(Resources resources, int resourceId) { int[] ...
1.Bitmap-->byte[]: public static byte[] Bitmap2Bytes(Bitmap bm) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.PNG, 100, baos); return baos.toByteArray(); } 2.byte[]-->Bitmap: public static Bitmap Bytes2Bimap(byte[] b) { if (b ...
public static Bitmap drawableToBitmap(Drawable drawable) { try { Bitmap bitmap = Bitmap .createBitmap( drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); ...
Android平台中的显示类是View,但是还提供了底层图形类android.graphics。     Bitmap - 称作位图,一般位图的文件格式后缀为bmp,当然编码器也有很多如RGB565、RGB8888。作为一种逐像素的显示对象执行效率高,但是缺点也很明显存储效率低。我们理解为一种存储对象比较好。     Drawable - 作为Android平下通用的图形对象,它可以装载常用格式的图像,比如GIF、PNG、JPG,当然也支持BMP,当然还提供一些高级的可视化对象,比如渐变、图形等。     Canvas - 名为画布,我们可以看作是一种处理过程,使用各种方法 ...
Android开发中用到的命令 一些命令,不常用就忘记了,特整理在这里,忘了就查查。。 * 创建Android虚拟设备(AVD) android create avd -n –name –t –target(1、2、3) * ddms(其文件管理功能) * 创建sdcard mksdcard –l label <size> <sdFilePath> * 启动模拟器 emulator –avd –name * 启动具有sdcard的模拟器 emulator –avd –name –sdcard <sdFilePath> * adb功能太多了 ...
[转]Android基本组件 Basic Components  1.         Activity 2.         Service  3.         Broadcast Receiver  4.         Content Provider  5.         Intent  Activity——应用表示层(基类Activity)        应用程序 ...
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#FFFF0000" android:endColor="#80FF00FF" android:angle="270"/> <padding android:left="50 ...
activity属性设置大全 android:allowTaskReparenting=["true" | "false"]         是否允许activity更换从属的任务,比如从短信息任务 切换到浏览器任务。 android:alwaysRetainTaskState=["true" | "false"]         是否保留状态不变, 比如切换回home, 再从新打开, activity处于最后的状态   android:clearTaskOnLaunch=["true&quo ...
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 duration).show() duration可以是:Toast.LENGTH_LONG,Toast.LENGTH_SHORT [Notification] 1,(NotificationM ...
使用styles.xml风格:   <style name="FullScreenDialog" parent="android:style/Theme.Dialog"> <item name="android:windowNoTitle">true</item> <item name="android:windowFrame">@null</item> <item name="android:windowIsFloati ...
Global site tag (gtag.js) - Google Analytics