标签:
Q:Android上面比较好的摇一摇
A:来源于开源社区,在比较多的Android品牌手机上测试效果好
private float lastX; private float lastY; private float lastZ; private long lastUpdateTime; private static final int SPEED_SHRESHOLD = 45;// 这个值越大需要越大的力气来摇晃手机 private static final int UPTATE_INTERVAL_TIME = 50; @Override public void onSensorChanged(SensorEvent event) { long currentUpdateTime = System.currentTimeMillis(); long timeInterval = currentUpdateTime - lastUpdateTime; if (timeInterval < UPTATE_INTERVAL_TIME) { return; } lastUpdateTime = currentUpdateTime; float x = event.values[0]; float y = event.values[1]; float z = event.values[2]; float deltaX = x - lastX; float deltaY = y - lastY; float deltaZ = z - lastZ; lastX = x; lastY = y; lastZ = z; double speed = (Math.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ) / timeInterval) * 100; if (speed >= SPEED_SHRESHOLD && !isRequest) { mLayoutBottom.setVisibility(View.GONE); vibrator.vibrate(300); onShake(); } }
在接口中的方法,添加修饰语“public”是多余的
Q:使用Android Studio打包APK
A:http://blog.csdn.net/sunylat/article/details/9239595,打包时碰到如下问题时Error:Execution failed for task ‘:app:proguardRelease‘. 解决办法:http://stackoverflow.com/questions/27506488/android-execution-failed-for-task-appproguardrelease/27575378;
打包时有如下错误时:Error:(5) Error: "xxx" is not translated in "xxx" [MissingTranslation],这是一个警告信息,修改参见http://www.codes51.com/article/detail_102407.html,更详细的tools介绍见http://blog.csdn.net/maosidiaoxian/article/details/41510581
Q:Android Studio常用功能介绍
A:http://ask.android-studio.org/?/article/23
Q:添加Android桌面快捷方式
A:参考:http://blog.csdn.net/liranke/article/details/23923693,注意权限添加
<!-- 添加快捷方式 --> <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> <!-- 移除快捷方式 --> <uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" /> <!-- 查询快捷方式 --> <uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" /> <uses-permission android:name="com.android.launcher3.permission.READ_SETTINGS" />
标签:
原文地址:http://www.cnblogs.com/EmbeddedBoy/p/4561826.html