随笔小计

来源:互联网 发布:停车软件排行 编辑:程序博客网 时间:2024/05/21 07:49

1.svn版本太低
sudo apt-get update
sudo apt-add-repository ppa:dominik-stadler/subversion-1.8
sudo apt-get update
sudo apt-get install subversion

2.framework里的东西,每次用到都会加载一次,可以直接拿到实例。

service里的都是在开机时SystemServer加载的,别的进程里都拿不到实例,只能跨进程调用。service里的对象实例,要是谁都能拿住,android就更不安全了

3.monkey测试:             android shell monkey -p 程序包名 -v 500

4.Activity获取和失去焦点(onWindowFocusChanged)

当启动一个Activity时,运行顺序:      onCreate–>onStart–>onResume–>onWindowFocusChanged(获得焦点)

跳转到另一个Activity时:       onPause–>onWindowFocusChanged(未获得焦点)

5../mk文件中加入LOCAL_PRIVILEGED_MODULE := true     将apk预编译到system/pri-app目录下

LOCAL_CERTIFICATE := platform    用系统签名签apk

6.android7.0状态栏下拉时弹出toast在状态栏之下

解决方法:

if (toast == null){    toast= makeText(mContext,mContext.getResources().getString(R.string.flashlight_tip_close_camera_first),            Toast.LENGTH_SHORT);} else {    toast.setText(mContext.getResources().getString(R.string.flashlight_tip_close_camera_first));    toast.setDuration(Toast.LENGTH_SHORT);}toast.setGravity(Gravity.BOTTOM,0,0);toast.show();
public static Toast makeText(Context context, CharSequence text, int duration) {    Toast toast = Toast.makeText(context, text, duration);    toast.getWindowParams().type = WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL;    toast.getWindowParams().privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;    toast.getWindowParams().flags |= WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;    return toast;}

7.SDK/tool/目录下的工具
层级观察器 (Hierarchy Viewer )
层级观察器工具允许你调试和优化你的用户界面。它用可视的方法把你的视图(view)的布局层次展现出来,此外还给当前界面提供了一个具有像素栅格(grid)的放大镜观察器,这样你就可以正确地布局了。
draw-9-patch
Draw 9-patch工具允许你使用所见即所得(WYSIWYG)的编辑器轻松地创建NinePatch图形。它也可以预览经过拉伸的图像,高亮显示内容区域。
android devices monitor

8.make update api   将修改内容与API的doc文件更新到一致.

9.某个程序被杀死了,可以在ActivityStack的destroyActivitiesLocked()中打堆栈查看。

10.模块编译时系统会已最近的Android.mk文件作为标准。(在编译framwork层的某些东西时选择最近的.mk文件;在编译Z502项目SoundRecorder时报错,tests文件中也有一个.mk文件)。

学习网址:

https://developer.android.google.cn/index.html

developers.google.cn
developer.android.google.cn
firebase.google.cn

.mk文件中导入jar包

LOCAL_STATIC_JAVA_LIBRARIES := \    android-support-v4 \    android-support-v7-recyclerview \    android-support-v7-preference \    android-support-v7-appcompat \

屏蔽home键

frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java

interceptKeyBeforeDispatching()中

if (keyCode == KeyEvent.KEYCODE_HOME) {    /**added by lhl for dispatch on Servicemenu*/    String title = win.getAttrs().packageName;    if (title != null && (title.equals("com.android.ServiceMenu") || "com.android.simple.camera".equals(title)            || "com.android.simple.camera".equals(title))){        return 0;    }}




0 0