ImageVerifierCode 换一换
格式:DOCX , 页数:31 ,大小:723.60KB ,
资源ID:16884759      下载积分:12 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/16884759.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(android学习笔记Word文档格式.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

android学习笔记Word文档格式.docx

1、 * param enable ture will be enable a app, false will be disable a app * describe enable/disable some application */ private boolean enableApp(Context ctx, String pName, boolean enable) boolean rslt =false; try Log.d(ctx.getClass().getSimpleName()+ pm enable app:+pName+,+enable); int targetState; if

2、(enable) targetState =PackageManager.COMPONENT_ENABLED_STATE_ENABLED; else targetState =PackageManager.COMPONENT_ENABLED_STATE_DISABLED; int newState = pm.getApplicationEnabledSetting(pName); if(newState!=targetState) pm.setApplicationEnabledSetting(pName,targetState,PackageManager.DONT_KILL_APP); L

3、og.d(ctx.getClass().getSimpleName()+ newState = pm.getApplicationEnabledSetting(pName); if(newState=targetState) rslt=true; catch (Exception e) return rslt;3 获取app的签名信息PackageInfo fromPageInfo ;fromPageInfo.signaturesi.toCharsString()4 网络判断 * check network is active or not, Thread will be not wait *

4、 return public static boolean netWorkConnectCheck(Context ctx) boolean rslt = false; ConnectivityManager connectivityManager = (ConnectivityManager) ctx.getSystemService( Context.CONNECTIVITY_SERVICE ); NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo(); if (activeNetInfo != null

5、 ) rslt =true; Log.d(Active Network Type : + activeNetInfo.getTypeName(); elseNetwork closed); return rslt; public static boolean checkURLReachable(String URL) URL url = new URL(URL); HttpURLConnection urlc = (HttpURLConnection)url.openConnection(); urlc.setConnectTimeout(5000); / mTimeout is in sec

6、onds urlc.connect(); if (urlc.getResponseCode() = 200) rslt=true; catch (Exception e) Log.d(cant Reachable:+URL); 【注意】还有Android系统自带API可以进行判断;5 单例实现public static GetTokenSynObjTY getInstance() if(instance=null) synchronized (GetTokenSynObjTY.class) if (instance = null) instance = new GetTokenSynObjTY

7、(); return instance;6 System权限获取1. 在应用程序的AndroidManifest.xml中的manifest节点中加入android:sharedUserId=android.uid.system这个属性。2. 使用eclipse编译出apk文件,但是这个apk文件是不能用的。3. 用压缩软件打开apk文件,删掉META-INF目录下的CERT.SF和CERT.RSA两个文件。4. 使用目标系统的platform密钥来重新给apk文件签名。这步比较麻烦,首先找到密钥文件,在Android源码目录中的位置是build/target/product/security

8、,下面的platform.pk8和platform.x509.pem两个文件。然后用Android提供的Signapk工具来签名,signapk的源代码是在build/tools/signapk下,用法为java -jar signapk.jar -w platform.x509.pem platform.pk8 input.apk output.apk.获取地址 文件/android开发笔记/常用组件/SignApk/7 获取APk签名信息工具Location: /android开发笔记/常用组件/SignApk_getSigns/Usage:java -jar SignatureTool.

9、jar apkpath(For example C:testtest.apk)8 隐藏软键盘if(imm.hideSoftInputFromWindow(this.getWindowToken(),0)/imm.showSoftInput(textView,0);returntrue;9 FlingGallery可以是图片 或者page等等文件/android开发笔记/常用组件/FlingGallery/10 GalleryFlow文件/android开发笔记/常用组件/GalleryFlow/这个Demo实现了类似iOS上面的CoverFlow功能。主要有两个功能1, 实现图片的倒影效果2,

10、重写gallery的一些方法实现Y轴上的旋转,Z轴上的缩放。11 Android Scroller简单用法文件 android开发笔记常用组件ScrollerDemo Android里Scroller类是为了实现View平滑滚动的一个Helper类。通常在自定义的View时使用,在View中定义一个私有成员mScroller = new Scroller(context)。设置mScroller滚动的位置时,并不会导致View的滚动,通常是用mScroller记录/计算View滚动的位置,再重写View的computeScroll(),完成实际的滚动。相关API介绍如下Java代码1. mSc

11、roller.getCurrX()/获取mScroller当前水平滚动的位置2. mScroller.getCurrY()/获取mScroller当前竖直滚动的位置3. mScroller.getFinalX()/获取mScroller最终停止的水平位置4. mScroller.getFinalY()/获取mScroller最终停止的竖直位置5. mScroller.setFinalX(intnewX)/设置mScroller最终停留的水平位置,没有动画效果,直接跳到目标位置6. mScroller.setFinalY(intnewY)/设置mScroller最终停留的竖直位置,没有动画效果,

12、直接跳到目标位置7. 8. /滚动,startX,startY为开始滚动的位置,dx,dy为滚动的偏移量,duration为完成滚动的时间9. mScroller.startScroll(intstartX,intstartY,dx,dy)/使用默认完成时间250ms10. mScroller.startScroll(intdy,duration)11. 12. mSputeScrollOffset()/返回值为boolean,true说明滚动尚未完成,false说明滚动已经完成。这是一个很重要的方法,通常放在VputeScroll()中,用来判断是否滚动是否结束。 举例说明,自定义一个Cus

13、tomView,使用Scroller实现滚动:1. importandroid.content.Context;2. importandroid.util.AttributeSet;3. importandroid.util.Log;4. importandroid.view.View;5. importandroid.widget.LinearLayout;6. importandroid.widget.Scroller;8. publicclassCustomViewextendsLinearLayout9. 10. privatestaticfinalStringTAG=Scroller

14、;12. ScrollermScroller;13. 14. publicCustomView(Contextcontext,AttributeSetattrs)15. super(context,attrs);16. mScrollernewScroller(context);17. 18. 19. /调用此方法滚动到目标位置20. voidsmoothScrollTo(intfx,fy)21. dxfx-mScroller.getFinalX();22. dyfymScroller.getFinalY();23. smoothScrollBy(dx,dy);24. 25. 26. /调用此

15、方法设置滚动的相对偏移27. smoothScrollBy(int28. 29. /设置mScroller的滚动偏移量30. mScroller.startScroll(mScroller.getFinalX(),mScroller.getFinalY(),31. invalidate();/这里必须调用invalidate()才能保证computeScroll()会被调用,否则不一定会刷新界面,看不到滚动效果32. 33. 34. Override35. computeScroll()36. 37. /先判断mScroller滚动是否完成38. if(mSputeScrollOffset()

16、39. 40. /这里调用View的scrollTo()完成实际的滚动41. scrollTo(mScroller.getCurrX(),mScroller.getCurrY();42. 43. /必须调用该方法,否则不一定能看到滚动效果44. postInvalidate();45. 46. puteScroll();47. 48. 12 欢迎界面文件android开发笔记常用组件WelcomPage/关于AndroidViewGroup的一点介绍:这里有个地方要注意,那就要明白ViewGroup的绘图流程:ViewGroup绘制包括两个步骤:1.measure 2.layout在两个步骤中

17、分别调用回调函数:1.onMeasure() 2.onLayout()1.onMeasure() 在这个函数中,ViewGroup会接受childView的请求的大小,然后通过childView的 measure(newWidthMeasureSpec, heightMeasureSpec)函数存储到childView中,以便childView的getMeasuredWidth() andgetMeasuredHeight() 的值可以被后续工作得到。2.onLayout() 在这个函数中,ViewGroup会拿到childView的getMeasuredWidth() andgetMeasu

18、redHeight(),用来布局所有的childView。3.View.MeasureSpec 与 LayoutParams 这两个类,是ViewGroup与childView协商大小用的。其中,View.MeasureSpec是ViewGroup用来部署 childView用的, LayoutParams是childView告诉ViewGroup 我需要多大的地方。4.在View 的onMeasure的最后要调用setMeasuredDimension()这个方法存储View的大小,这个方法决定了当前View的大小。效果图:13 程序退出处理1) Finish所有Activity, 2) s

19、top 所有Services3) kill Process, android.os.Process.killProcess(android.os.Process.myPid();System.exit(0);14 使用提醒管理器 延迟发送广播PendingIntent dd =PendingIntent.getBroadcast(activity, 0, intent, 0);AlarmManager mgr = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);mgr.set(AlarmManager.RTC, S

20、ystem.currentTimeMillis() + 2000, dd);15 xUtils简介 xUtils 包含了很多实用的android工具。 xUtils 最初源于Afinal框架,进行了大量重构,使得xUtils支持大文件上传,更全面的http请求协议支持(10种谓词),拥有更加灵活的ORM,更多的事件注解支持且不受混淆影响. 详情16 android 常用调用系统功能16.1 从google搜索内容 Intent intent = new Intent(); intent.setAction(Intent.ACTION_WEB_SEARCH); intent.putExtra(S

21、earchManager.QUERY,searchString startActivity(intent);16.2 浏览网页 Uri uri =Uri.parse( Intent it = new Intent(Intent.ACTION_VIEW,uri); startActivity(it);16.3 显示地图 Uri uri = Uri.parse(geo:38.899533,-77.036476 Intent it = newIntent(Intent.Action_VIEW,uri);16.4 路径规划 Intent it = newIntent(Intent.ACTION_VIE

22、W,URI);16.5 拨打电话tel:xxxxxx Intent it = new Intent(Intent.ACTION_DIAL,uri);16.6 调用发短信的程序 方法1: Intent it = newIntent(Intent.ACTION_VIEW); it.putExtra(sms_body, TheSMS text it.setType(vnd.android-dir/mms-sms16.7 发送短信 方法2:smsto:0800000123 Intent it = newIntent(Intent.ACTION_SENDTO, uri); 方法三: String bod

23、y=this is sms demo Intent mmsintent = newIntent(Intent.ACTION_SENDTO, Uri.fromParts(smsto, number, null); mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY,body); mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE,true); mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT,true); startActivity(mmsintent);16.8 发送彩信content:/media/external/images/media/23 Intent it = newIntent(Intent.ACTION_SEND);some text it.putExtra(Intent.EXTRA_STREAM, uri);image/png Str

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1