自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(38)
  • 收藏
  • 关注

原创 Android项目笔记:JobService

在Android5.0之后,系统为我们提供了一个后台定时任务,在特定的条件下触发。它就是JobService。JobService在满足条件的情况下,会在APP的主线程中执行任务。因此需要我们注意不能直接执行耗时的任务。JobService的使用首先要先申请一个保护权限 "android.permission.BIND_JOB_SERVICE" ,否则系统将跳过这个JobService。<s...

2018-03-29 19:29:37 2320

原创 Android中注解的简单使用

前言注解最常见的用法就是去掉繁琐的findviewbyId方法,通过注解的方式绑定控件,代替findviewbyId和强制类型转换。能使代码更简洁。@ViewInject(id = R.id.tx1)private TextView textView;@ViewInject(id = R.id.button)private Button button;下面介绍Android中注解

2017-12-12 19:57:24 659

原创 Leetcode 102. Binary Tree Level Order Traversal

Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 2

2016-07-06 21:25:40 355

原创 Leetcode 101. Symmetric Tree

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3 4 4 3

2016-07-06 21:01:08 288

原创 Leetcode 98. Validate Binary Search Tree

Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node's key.Th

2016-06-30 21:27:40 294

转载 Android 插件化原理解析——插件加载机制

上文 Activity生命周期管理 中我们地完成了『启动没有在AndroidManifest.xml中显式声明的Activity』的任务;通过Hook AMS和拦截ActivityThread中H类对于组件调度我们成功地绕过了AndroidMAnifest.xml的限制。但是我们启动的『没有在AndroidManifet.xml中显式声明』的Activity和宿主程序存在于同一个Apk中;

2016-06-30 15:39:01 3379

原创 Leetcode 94. Binary Tree Inorder Traversal

递归的方法:public class Solution { public ArrayList inorderTraversal(TreeNode root) { ArrayList list = new ArrayList(); if(root != null){ list.addAll(inorderTraversal(root

2016-06-29 22:17:18 223

原创 Leetcode 144. Binary Tree Preorder Traversal

Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].Note: Recursive soluti

2016-06-29 20:54:04 238

原创 Leetcode 145. Binary Tree Postorder Traversal

Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].Note: Recursive solut

2016-06-29 20:25:06 226

原创 Leetcode 110. Balanced Binary Tree

Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe

2016-06-29 20:09:12 210

转载 Android 插件化原理解析——Hook机制之AMS&PMS

在前面的文章中我们介绍了DroidPlugin的Hook机制,也就是代理方式和Binder Hook;插件框架通过AOP实现了插件使用和开发的透明性。在讲述DroidPlugin如何实现四大组件的插件化之前,有必要说明一下它对ActivityManagerServiche以及PackageManagerService的Hook方式(以下简称AMS,PMS)。ActivityManagerS

2016-06-29 17:23:34 3084

转载 Android插件化原理解析——Hook机制之Binder Hook

Android系统通过Binder机制给应用程序提供了一系列的系统服务,诸如ActivityManagerService,ClipboardManager, AudioManager等;这些广泛存在系统服务给应用程序提供了诸如任务管理,音频,视频等异常强大的功能。插件框架作为各个插件的管理者,为了使得插件能够无缝地使用这些系统服务,自然会对这些系统服务做出一定的改造(Hook),使得插件的

2016-06-29 16:53:25 563

转载 Android插件化原理解析——Hook机制之动态代理

使用代理机制进行API Hook进而达到方法增强是框架的常用手段,比如J2EE框架Spring通过动态代理优雅地实现了AOP编程,极大地提升了Web开发效率;同样,插件框架也广泛使用了代理机制来增强系统API从而达到插件化的目的。本文将带你了解基于动态代理的Hook机制。阅读本文之前,可以先clone一份 understand-plugin-framework,参考此项目的dynamic-

2016-06-29 16:16:18 778

原创 Shared storage cannot protect your application from code injection attacks

在动态加载dex的时候可能会出现以下问题: java.lang.IllegalArgumentException: Optimized data directory /storage/emulated/0 is not owned by the current user. Shared storage cannot protect your application from code in

2016-06-29 15:32:45 1586

原创 Leetcode 117. Populating Next Right Pointers in Each Node II

Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use constant

2016-06-28 21:12:36 279

原创 Leetcode 112. Path Sum

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree andsum =

2016-06-28 20:23:04 190

原创 Leetcode 116. Populating Next Right Pointers in Each Node

Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node.

2016-06-28 20:20:19 296

原创 LeetCode 299. Bulls and Cows

You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint t

2016-06-22 21:19:30 245

原创 Error:Execution failed for task ':app:transformClassesWithDexForDebug

引入之前在eclipse下开发的项目到AndroidStudio 遇到了如下错误:Error:Execution failed for task ':guanXiang:transformClassesWithDexForDebug'.> com.android.build.api.transform.TransformException: com.android.ide.common.pr

2016-06-22 15:44:40 4721

原创 LeetCode 111. Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node./** * Definition for a bina

2016-06-21 17:13:24 192

原创 LeetCode 113. Path Sum II

Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum = 22, 5 / \

2016-06-21 16:51:15 176

原创 Leetcode 104. Maximum Depth of Binary Tree

Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node./** * Definition for a bina

2016-06-17 16:29:15 62

原创 LeetCode 107. Binary Tree Level Order Traversal II

Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree {3,9,20,#,#,15,7},

2016-06-17 16:26:49 343

原创 RuntimeException: Canvas: trying to use a recycled bitmap

在写瀑布流图片加载的时候出现了一个错误  Canvas: trying to use a recycled bitmap 从log可以找到错误的源头@Override protected void onDestroy() { super.onDestroy(); // Bitmap对象回收掉 if (bitmap != null)

2016-06-16 21:31:04 892

原创 等待通知机制 wait,notify,notifyAll

一、等待通知机制 相关方法等待通知的相关方法是任意java对象都具备的,因为这些方法被定义在Object类中。名称  描述notify 通知一个在对象上wait的线程,使其返回。返回的前提是该线程获得了对象的锁,即监视器monitornotifyAll通知所有等待的线程wait

2016-06-15 21:31:35 653

原创 Exception:must implement OnFragmentInteractionListener

转载请注明出处:http://blog.csdn.net/parallelyk今天写代码的时候发现,用Android Studio创建一个blank Fragment的时候会为我们创建一个Fragment的模板。public class MainFragment extends Fragment { // TODO: Rename parameter arguments, ch

2016-05-26 21:30:49 3637 2

转载 Android 属性动画

Property Animation是如何运作的首先,来看一下两个不一样的Property Animation场景:场景一(Linear Animation):Animation要求一个物体A的x属性在40ms内匀速地从0px变化到40px。帧的刷新率默认为10ms/帧。场景二(Not-Linear Animation):Animation要求一个物体A的x属性在40ms内先加速后

2016-05-24 15:41:22 263

转载 Binder设计详解

Binder是Android系统进程间通信(IPC)方式之一。Linux已经拥有管道,system V IPC,socket等IPC手段,却还要倚赖Binder来实现进程间通信,说明Binder具有无可比拟的优势。深入了解Binder并将之与传统IPC做对比有助于我们深入领会进程间通信的实现和性能优化。本文将对Binder的设计细节做一个全面的阐述,首先通过介绍Binder通信模型和Binder通

2016-05-23 16:31:19 129

原创 Android延时启动任务的方法

开启新线程 new Thread(new Runnable(){ public void run(){ Thread.sleep(XXXX); handler.sendMessage(); //告诉主线程执行任务 } }).start 利用定时器TimerTask tas

2016-05-23 16:29:14 653

转载 简述网络爬虫的系统实现

网络爬虫常常被人所忽略,特别是和搜索引擎的光环相比,它似乎有些暗淡无光。我很少看见有详细介绍爬虫实现的文章或者文档。然而,爬虫其实是非常重要的一个系统,特别是在今天这个数据为王的时代。如果你是一个刚刚开始的公司或者项目,没有任何原始的数据积累,那么通过爬虫去Internet上找到那些有价值的数据再进行数据的清洗和整理,是一个可以快速得到数据的重要手段。本文侧重于爬虫的系统设计和实现的部分细

2015-06-02 14:35:18 446

转载 一致性hash算法 - consistent hashing

一致性 hash 算法( consistent hashing )张亮consistent hashing 算法早在 1997 年就在论文 Consistent hashing and random trees 中被提出,目前在cache 系统中应用越来越广泛;1 基本场景比如你有 N 个 cache 服务器(后面简称 cache ),那么如何将一个对象 object 映射到 N 

2015-05-25 13:03:25 270

原创 鸟哥的私房菜基础篇--第三部分 读书笔记

1.vim的使用:需要熟练各种操作。详见vim常用命令。2.bash相关type 可以知道每个命令是否为bash的内置命令。echo用来显示变量时,变量在被显示时,前面必须要加上字符$如echo $PATH 或者 echo ${PATH}export 可以用来使变量变成环境变量 一般父进程的自定义变量是无法在子进程中使用的,所以可以通过使用export来达到目的un

2015-04-17 11:26:17 258

转载 Linux GCC常用命令

1简介2简单编译2.1预处理2.2编译为汇编代码(Compilation)2.3汇编(Assembly)2.4连接(Linking)3多个程序文件的编译4检错5库文件连接5.1编译成可执行文件5.2链接5.3强制链接时使用静态链接库1简介GCC 的意思也只是 GNU C Compiler 而已。经过了这么多年的发展,GCC 已经不仅仅能支持 C

2015-04-10 13:19:14 483

转载 vim 常用命令

vim 选择文本,删除,复制,粘贴  文本的选择,对于编辑器来说,是很基本的东西,也经常被用到,总结如下:v    从光标当前位置开始,光标所经过的地方会被选中,再按一下v结束。 V    从光标当前行开始,光标经过的行都会被选中,再按一下V结束。 Ctrl + v   从光标当前位置开始,选中光标起点和终点所构成的矩形区域,再按一下Ctrl + v结束。 

2015-04-10 13:16:52 244

原创 鸟哥的私房菜基础篇--第二部分 读书笔记

Linux里面,每个文件都有User,Group,Other三个身份权限。     su 可以用于切换用户,后面不加命令时为切换到root         Linux的文件属性:         -ls list的意思。显示文件名和相关属性。一般会显示7项。         从左到右如下:         -rw-r--r-- 1 root root 102

2015-03-19 12:32:32 372

原创 鸟哥的私房菜基础篇--第一部分 读书笔记

在linux中,每个设备都被当做一个文件来对待。比如IDE接口的硬盘的文件名即为/dev/hd[a-d]。     磁盘的第一个扇区主要记录了两个重要的信息,分别是:     1.主引导分区(MBR),可以安装引导加载程序的地方,有446字节     2.分区表,记录整块硬盘分区的状态,有64字节     在分区表的64个字节中,总共分为四组记录区。每组记录区记录了该区段的

2015-02-01 22:33:47 411

原创 ubuntu14.04 鼠标闪烁问题

重新装了ubuntu,结果发现鼠标老是闪烁,而且会跑到屏幕的右边去,拖动起来也怪怪的。    然后上网查了一下,发现是由于双显卡的原因,我的是一个集成显卡和一个独显。好像因此会有两个显示器。(具体原因是否如此未考证)    解决方法很简单:打开系统设置,再打开里面的“显示”,不出意外可以看到两个“内置显示器”的东西。只要关闭掉其中一个就ok啦。(我是关了右边那个。。)

2015-01-29 18:02:43 249

原创 动态共享对象的装载时重定位

最近读程序员的自我修养--链接 装载与库,其中有句话:动态链接模块被装载映射到虚拟空间后,指令部分是在多个进程之间共享的,由于装载时重定位的方法需要修改指令,所以没有办法做到同一份指令被多个进程共享,因为指令被重定位后对于每个进程来讲是不同的。一直没搞懂,花了不少时间查阅资料,了解原理。觉得自己一直理解的东西都太浅了。 以下是对这块内容的总结,作为记录。其中的关键点在于掌握内存映射,重定位的实

2015-01-15 20:23:23 3584 11

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除