- 博客(20)
- 资源 (10)
- 收藏
- 关注
转载 Intent 传值和 Bundle传值的区别
转载:http://blog.csdn.net/yanzi1225627/article/details/7802819举个例子 我现在要从A界面 跳转到B界面或者C界面 这样的话 我就需要写2个Intent 如果你还要涉及的传值的话 你的Intent就要写两遍添加值的方法 那么 如果我用1个Bundle 直接把值先存里边 然后再存到Intent中 不就更简洁吗?另外一个例子 如果我现
2016-01-29 21:50:53 614
转载 LruCache类
Android用LruCache来取代原来强引用和软引用实现内存缓存,因为据说自2.3以后Android将更频繁的调用GC,导致软引用缓存的数据极易被释放。LruCache使用一个LinkedHashMap简单的实现内存的缓存,没有软引用,都是强引用。如果添加的数据大于设置的最大值,就删除最先缓存的数据来调整内存。他的主要原理在trimToSize方法中。需要了解两个主要的变量size和maxSiz
2016-01-28 22:36:34 506
原创 单例Toast
public class SingleToastUtils { private static Toast toast; public static void getSingleToast(Context context, String text) { if (toast == null) { //创建一个空的吐司 toas
2016-01-28 21:47:39 871
原创 AsyncTask的使用
public class MainActivity extends AppCompatActivity { private Button btn; private ProgressBar pb; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(save
2016-01-28 21:38:13 335
原创 单例模式
单例模式分为:饿汉式和懒汉式类图: 饿汉式:public class SingleBitmap {/** * 饿汉式 */ private static SingleBitmap sSingleBitmap = new SingleBitmap(); private SingleBitmap() { }/** * 饿汉式 * @return */ public
2016-01-28 21:00:38 806
原创 点击2次Back键退出程序
有2种方法,一种是通过handler发送消息,一种是通过点击2次按下Back键的事件间隔来判断,后退出程序。个人比较倾向handler的方式public class MainActivity extends Activity { private boolean isExit = false;// 定义一个标记 private long exitTime = -1;// 声明一个退出时间
2016-01-27 22:43:24 597
原创 闪动文字效果
自定义一个Viewpublic class MyView extends TextView { private int mViewdWidth; private TextPaint mPaint; private LinearGradient mLinearGradient; private Matrix matrix; private int mTransla
2016-01-27 22:37:52 470
转载 Android activity属性设置大全
Android activity属性设置大全 android:allowTaskReparenting=[“true” | “false”] 是否允许activity更换从属的任务,比如从短信息任务 切换到浏览器任务。android:alwaysRetainTaskState=[“true” | “false”] 是否保留状态不变, 比如切换回home, 再从新打
2016-01-25 22:52:55 783
原创 Android 切换日夜间模式
在attrs.xml文件中配置属性 <attr name="mainBackground" format="color"/>在layout.xml文件中使用<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" androi
2016-01-25 22:08:17 1401 1
原创 消息摘要(MessageDigest)
常见算法:MD5,SHA,CRC等使用场景: 1.对用户密码进行MD5加密后保存到数据库里 2.软件下载站使用消息摘要计算文件指纹,防止被篡改 3.数字签名public class MessageDigestDemo { public static void main(String[] args) throws NoSuchAlgorithmException { St
2016-01-23 23:19:36 949
原创 非对称加密
非对称加密算法需要两个密钥:公钥和私钥 公钥和私钥是一对的,如果用公钥数据进行加密,只有用对应的私钥才能解密:如果用私钥对数据加密,那么只有用公钥才能解密。常见的算法:RSA、Elgamal等应用场景: 1.银行/电商等网站,银行将公钥公布出去,大家都能使用,是要自己保存,用户传输过去的信息,只有银行能用私钥进行解密。 2.加密对称加密的密钥。/** * 非对称加密 */public c
2016-01-23 23:18:36 1026
原创 RSA算法原理演示
RSA算法原理演示 计算公钥和密钥 假设p = 3、q = 11(p,q都是素数即可。),则N = pq = 33; r = (p-1)(q-1) = (3-1)(11-1)= 20; 根据模反元素的计算公式,我们可以得出,e·d ≡ 1 (mod 20),即e·d = 20n+1 (n为正整数);我们假设n=1,则e·d =21。e、d为正整数,并且e与r互质,则e = 3,d = 7。(两个数交
2016-01-23 23:16:52 1174
原创 对称加密
对称加密常用的几种:DES,AES,3DES等对称加密应用场景 1.本地数据加密(sp) 2.网络传输(post请求username=li,psw=jsdcaaosiiJDJJ(对密码进行了加密)) 3.加密用户登入结果信并序列化到本地磁盘 4.网页交互数据加密/** * 生成秘钥并保存到硬盘上,之后读取该秘钥进行加密解密操作 */public class SymmetricalEnc
2016-01-23 23:15:07 641
原创 频率分析法破解凯撒密码
/** * 频率分析法破解凯撒密码 */public class FrequencyAnalysis { //英文里出现次数最多的字符 private static final char MAGIC_CHAR = 'e'; //破解生成的最大文件数 private static final int DE_MAX_FILE = 4; public stati
2016-01-23 23:13:09 7830
原创 凯撒密码--简单的加密与解密
凯撒密码–简单的加密与解密public class MyEncrypt { private static final int KEY = 3; public enum EncryptState { ENCRYPT, //表示加密操作 DECRYPT //表示解密操作 } public static void main(Strin
2016-01-23 23:09:15 4302
原创 aidl的简单使用
aidl–进程间的通信(就是2个app之间的通讯)app1–表示服务的提供者–例如支付包的支付方法,需要对外暴露,让其他app调用其功能创建一个AliPay.aidl文件–将java的后缀改为aidl interface AliPay { String pay(float menoy);}注意:aidl中是不能有修饰符的,否则报错在app1中的AliPayService 中public
2016-01-22 23:14:25 509
原创 监听输入法键盘的事件
布局文件<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <!-
2016-01-22 23:08:24 886
原创 捕获全局异常
自定义一个Applicationpublic class MyApplication extends Application implements UncaughtExceptionHandler { @Override public void onCreate() { super.onCreate();// 此方法为空实现--可以删除 T
2016-01-22 23:06:41 631
原创 自定义权限
1.自定义权限应用程序之间或同应用的activity\service中发送一个广播。 以应用程序之间为例:/**这是发送广播的应用程序*/public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstan
2016-01-22 22:57:06 591
Gradle for Android
2016-11-15
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人