android
hello7778
I am who I am;
展开
-
实现点击两次返回键退出app
long eTime;public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if ((System.currentTimeMillis() - eTime) > 2000) { Custom转载 2017-07-25 16:04:27 · 552 阅读 · 0 评论 -
android px dp 互换工具
/** * dp ---> px */ public static int dp2px(Context context, float dp) { float ratio = context.getResources().getDisplayMetrics().density; return (int) (dp * ratio原创 2017-07-26 11:37:16 · 290 阅读 · 0 评论 -
android6.0敏感权限动态申请
//判断是否为android6.0系统版本,如果是,需要动态添加敏感权限 if (Build.VERSION.SDK_INT>=23){ checkPopedom(); } private void checkPopedom(){ if (ActivityCompat.checkSelfPermission(this,原创 2017-07-26 09:26:28 · 481 阅读 · 0 评论 -
手机号合法验证
//原创 2017-07-25 17:34:44 · 345 阅读 · 0 评论 -
解决没有绑定view而弹出popupwindow
popupwindow.showAtLocation(context.getWindow().getDecorView(), Gravity.CENTER, 0, 0);利用context.getWindow().getDecorView()来获取Window界面的最顶层View这样可以解决在后台接受到数据时候后没有绑定布局的时候不能弹出popupwindow的问题这样我们原创 2017-07-25 17:12:20 · 502 阅读 · 0 评论 -
复制内容至粘贴板
ClipboardManager cm = (ClipboardManager) getSystemService(context.CLIPBOARD_SERVICE);String content = "test str";cm.setText(content);原创 2017-07-25 16:32:21 · 252 阅读 · 0 评论 -
解决popwindow在点击退出后背景透明度不能还原的问题
问题出现:通过上一篇文章当我们点击取消popupwindow之后背景透明图层不能恢复 设置无效解决思路:给popwindow设置一个ondismisslistener时间 在触发这个事件之后就让背景颜色消失.pop.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override p原创 2017-07-25 17:02:04 · 649 阅读 · 0 评论 -
解决PopupWindow弹出后背景变暗的问题 背景透明度
/** * 设置添加屏幕的背景透明度 * @param bg_alpha 1.0f 全透明没有阴影 */public void backgroundAlpha(float bg_alpha){ WindowManager.LayoutParams lp = getWindow().getAttributes(); lp.alpha = bg_alpha; //原创 2017-07-25 16:52:00 · 740 阅读 · 0 评论 -
adb shell 模拟长按屏幕
adb shell input swipe 100 100 100 100 1000 //在 100 100 位置长按 1000毫秒原创 2017-07-25 16:34:00 · 9358 阅读 · 3 评论 -
android 显示刚刚下载的图片
1.下载路径String path1 = Environment.getExternalStorageDirectory().getAbsolutePath() + "/DCIM/Camera";2.adb shell 刷新图库am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file:///sto原创 2017-07-25 16:24:57 · 235 阅读 · 0 评论 -
adb shell 终止应用程序
adb shell am force-stop原创 2017-07-25 16:21:41 · 6313 阅读 · 0 评论 -
android alertdialog 相关设置
//前面代码省略 dialog.setView(view); dialog.show(); //设置要放在show()方法之后 Window dialogWindow = dialog.getWindow(); //设置AlertDialog位置 dialogWindow原创 2017-07-26 11:49:51 · 265 阅读 · 0 评论