Menu Home


iOS:How to get your framework version using code

Add these lines in your Framework header file. eg. PrefixFramework.h //! Project version number for LocalSearch. FOUNDATION_EXPORT double PrefixFrameworkVersionNumber; //! Project version string for LocalSearch. FOUNDATION_EXPORT const unsigned char PrefixFrameworkVersionString[]; There arguments will be filled by iOS framework logic.And you can get the version like this: +(NSString*) playerVersion { NSRange […]

Android FW: Create Floating Window

private void initFloatingWindow() { mWindowManager = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); mWindow = PolicyManager.makeNewWindow(mContext); mWindow.setWindowManager(mWindowManager, null, null); mWindow.requestFeature(Window.FEATURE_NO_TITLE); mDecor = mWindow.getDecorView(); mDecor.setOnTouchListener(mTouchListener); mWindow.setContentView(this); mWindow.setBackgroundDrawableResource(android.R.color.transparent); // While the media controller is up, the volume control keys should // affect the media stream type mWindow.setVolumeControlStream(AudioManager.STREAM_MUSIC); setFocusable(true); setFocusableInTouchMode(true); setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); requestFocus(); } ref:

Android: Check Long Press Helper

基本思想: 在Down事件中向UI线程塞入一个定时任务,如果在定时时间终了前任务没有被取消,就认为是一个长按事件。 /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the “License”); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * * […]

Android:How to change MTP and PTP name

Android OS: 4.4.4 Sometimes, you want to change the default MTP/PTP name of your android device. If you have android source, it’s very easy. First open the source file: frameworks/base/media/java/android/mtp/, Line:799(in my source), or you can search the function getDeviceProperty private int getDeviceProperty(int property, long[] outIntValue, char[] outStringValue) { switch […]


把需要增加的图片资源放到 frameworks/base/core/res/res/drawable-nodpi,如果就这样直接应用这个资源,会出现找不到资源的错误。实际上在增加完资源后还需要在 frameworks/base/core/res/res/values/symbols.xml文件中做相应的注册,比如: <java-symbol type=”drawable” name=”my_wallpaper” /> 重新编译framework-res后就可以使用这个资源了:

Android Framework: 重启代码

private void RebootIntoRecovery() { PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); pm.reboot(“recovery”); } <uses-permission android:name=”android.permission.REBOOT” /> <manifest xmlns:android=”” package=”” coreApp=”true” android:sharedUserId=”android.uid.system”>

Android电源管理-Healthd (2)

接上文 Android电源管理-Healthd (1) adb shell进入到/sys/class/power_supply目录,我们可以看到power_supply驱动创建的一些运行时文件(我的设备是Nuxus 7, Android 4.4.2, kernel 3.4.0): adb root adb shell cd /sys/class/power_supply ll 输出如下: lrwxrwxrwx root root 2014-09-19 14:30 ac -> ../../devices/i2c-0/0-0055/power_supply/ac lrwxrwxrwx root root 2014-09-19 14:30 battery -> ../../devices/i2c-0/0-0055/power_supply/battery lrwxrwxrwx root root 2014-09-19 14:30 usb -> ../../devices/i2c-0/0-0055/power_supply/usb lrwxrwxrwx root root 2014-09-19 14:30 wireless -> ../../devices/i2c-0/0-0055/power_supply/wireless […]