随笔分类 - Android
摘要:一、背景如果要自己搭建,从零开始做或基于开源进行修改扩充,开源的push引擎,90%的博文首推AndroidPN,结合公司现状,最优解决方案就是进行AndroidPN的二次开发了。先看一下这个项目:这是韩国人放在 sourceforge.net 上的一个开源项目,文档是韩文的。最近的版本更新时间是 2010-11-05,也就是约二年之前。来自中国的访问量,占其总访问量的 81%。统计链接:http...
阅读全文
摘要:一. 常见的推送原理: 1)轮询(Pull)方式:应用程序应当阶段性的与服务器进行连接并查询是否有新的消息到达,你必须自己实现与服务器之间的通信,例如消息排队等。而且你还要考虑轮询的频率,如果太慢可能导致某些消息的延迟,如果太快,则会大量消耗网络带宽和电池。 2)SMS(Push)方式:在Android平台上,你可以通过拦截SMS消息并且解析消息内容来了解服务器的意图,并获取其显示内容进行处理。这是一个不错的想法,我就见过采用这个方案的应用程序。这个方案的好处是,可以实现完全的实时操作。但是问题是这个方案的成本相对比较高,我们需要向移动公司缴纳相应的费用。我们目前很难找到免费的短消息发送...
阅读全文
摘要:在cmd窗口一条命令就可以了:adb shellmount -o remount rw /
阅读全文
摘要:There are several occasions when the unique identifier of a device is required. For instance you need it to generate a serial key and unlock a trial version, to generate encryption keys or to have the unique signature of a device.On Android there are several ways to get such an ID.The IMEIPseudo-Uni
阅读全文
摘要:GC rootsThe so-called GC (Garbage Collector) roots are objects special for garbage collector. Garbage collector collects those objects that are not GC roots and are not accessible by references from GC roots.There are several kinds of GC roots. One object can belong to more than one kind of root. Th
阅读全文
摘要:startService:正常调用:onCreate->onStart取消绑定:onDestroy如果调用者自己直接退出而没有调用stopService,则Service会一直在后台运行,直到下次调用者再启动起来,并明确调用stopServicebindService正常调用:onCreate->onBind取消绑定:onUnbind->onDestroy先startService,再bindServiceonCreate->onStart->onBind(onCreate只调用一次)先stopService 再unbindService点stopService不
阅读全文
摘要:Class OverviewAsyncTask enables proper and easy use of the UI thread. This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers.AsyncTask is designed to be a helper class around Thread and Handler and does not constit
阅读全文
摘要:@TargetApi and @SuppressLint have the same core effect: they suppress the Lint error.The difference is that with @TargetApi, you declare, via the parameter, what API level you have addressed in your code, so that the error can pop up again if you later modify the method to try referencing something
阅读全文
摘要:android系统中的每个ViewGroup的子类都具有下面三个和TouchEvent处理密切相关的方法: 1)public boolean dispatchTouchEvent(MotionEvent ev) 这个方法用来分发TouchEvent 2)public boolean onInterceptTouchEvent(MotionEvent ev) 这个方法用来拦截TouchEvent 3)public boolean onTouchEvent(MotionEvent ev) 这个方法用来处理TouchEvent 注意:不是所有的View的子类,很多教程都...
阅读全文
摘要:An Executor that provides methods to manage termination and methods that can produce a Future for tracking progress of one or more asynchronous tasks.An ExecutorService can be shut down, which will cause it to reject new tasks. Two different methods are provided for shutting down an ExecutorService.
阅读全文
摘要:AsyncTask实际上就是一个线程池,AsyncTask在代码上比handler要轻量级别,而实际上要比handler更耗资源,因为AsyncTask底层是一个线程池!而Handler仅仅就是发送了一个消息队列,连线程都没有开。但是,如果异步任务的数据特别庞大,AsyncTask这种线程池结构的优势就体现出来了。android的ui线程操作并不是安全的,并且和用户直接进行界面交互的操作都必须在ui线程中进行才可以。这种模式叫做单线程模式。我们在单线程模式下编程一定要注意:不要阻塞ui线程、确保只在ui线程中访问ui组件AsyncTask是抽象类,定义了三种泛型类型 Params,Prog..
阅读全文
摘要:public abstract classAsyncQueryHandlerextendsHandlerA helper class to help make handling asynchronousContentResolverqueries easier.使用场景:在一般的应用中可以使用ContentProvider去操作数据库。这在数据量很小的时候是没有问题的,但是如果数据量大了,可能导致UI线程发生ANR异常(超过5秒)。当然你也可以写个Handler去做这些操作,只是你每次使用ContentProvider时都要再写个Handler,必然降低了效率。因此当数据量较大时,最好还是使用
阅读全文
摘要:2012-12-19 统计的当前android手机主要分辨率,主要来源于中关村。看完以下数据统计之后,请决定dm版要采用的分辨率,谢谢商超通dm版本,支持分辨率和对应的android手机如下:当前市面上可见的分辨率 说明 中关村数据(包括已停产)1280×720像素 ---大部分高档机型,高清屏,该类手机越来越多 127款手机960×640像素--主要是魅族系列手机 12款手机960×540像素--相对分散,htc,摩托居多 163款手机854×480像素---相对分散,主要是摩托,联想 98款80...
阅读全文
摘要:Androidis aLinux-basedoperating systemdesigned primarily fortouchscreenmobile devices such assmartphonesandtablet computers. Initially developed by Android, Inc.,whomGooglefinancially backed and laterpurchased in 2005,Android was unveiled in 2007along with the founding of theOpen Handset Allianc...
阅读全文
摘要:Android is a software stack for mobile devices that includes an operating system, middleware and key applications. TheAndroid SDKprovides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language.FeaturesApplication frameworkenabling ..
阅读全文
摘要:o(∩_∩)oString result = String.format("The format method is %s!", "great");// result now equals "The format method is great!".You don't need to use numbers to indicate positioning. By default, the position of the argument is simply the order in which it appears in th
阅读全文
摘要:1.android:configChanges="keyboardHidden|orientation"<activity android:name=".TwitterActivity$AppListFragment" android:configChanges="keyboardHidden|orientation" />If you use this,then android won't restart activity when screen is rotated.Instead,onConfiguratio
阅读全文
摘要:These classes focus on the best Android user experience for your app. In some cases, the success of your app on Android is heavily affected by whether your app conforms to the user's expectations for UI and navigation on an Android device. Follow these recommendations to ensure that your app loo
阅读全文
摘要:A.Drawable1.Background for icon,view,color bg_(type)_(name).xml/png bg_color_gray.xml bg_color_round_gray.xml bg_btn_wooden.png bg_btn_store_dt.p...
阅读全文
摘要:UseonSaveInstanceState() to save the states of the activity and resume it in onCreate()Usually you restore your state inonCreate(). It is possible to restore it inonRestoreInstanceState()as well, but not very common. (onRestoreInstanceState()is called afteronStart(), whereasonCreate()is called befor
阅读全文

浙公网安备 33010602011771号