智慧云端日记

Just do IT


  • 首页

  • 归档

  • 标签

  • 捐赠列表

  • 搜索
close

Android极速开发之设备管理器

发表于 2016-09-03   |   分类于 Android , Android极速开发   |     |   阅读次数

继续来总结一些常用封装。

欢迎留言、转发、打赏

项目源码参考地址 点我点我–欢迎Start

阅读全文 »

Android极速开发之桌面快捷方式

发表于 2016-08-31   |   分类于 Android , Android极速开发   |     |   阅读次数

欢迎留言、转发、打赏

项目参考地址:参考代码

阅读全文 »

Android极速开发之手机屏幕

发表于 2016-08-27   |   分类于 Android , Android极速开发   |     |   阅读次数
  • 获取屏幕宽高
  • 手机横竖屏的判断
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class ScreenUtils {
public static int getWidth(Context context) {
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics outMetrics = new DisplayMetrics();
manager.getDefaultDisplay().getMetrics(outMetrics);
return outMetrics.widthPixels;
}
public static int getHeight(Context context) {
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics outMetrics = new DisplayMetrics();
manager.getDefaultDisplay().getMetrics(outMetrics);
return outMetrics.heightPixels;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class ConfigUtils {
public static boolean isOrientationPortrait(Context context) {
if (context.getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_PORTRAIT) {
return true;
}
return false;
}
public static boolean isOrientationLandscape(Context context) {
if (context.getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_LANDSCAPE) {
return true;
}
return false;
}
}

Android极速开发之调节屏幕的亮度

发表于 2016-08-27   |   分类于 Android , Android极速开发   |     |   阅读次数

屏幕亮度调节

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//设置应用中的亮度 不保存
public void Brightness(View view){
boolean autoBrightness = BrightnessTools.isAutoBrightness(getContentResolver());
if (autoBrightness) {
T.showLong(this, "关闭自动调节亮度");
BrightnessTools.stopAutoBrightness(this);
}
BrightnessTools.setBrightness(this, 255);
T.showLong(this, "亮度已经设置为了最大");
}
//获取当前亮度 并设置最大的亮度保存
public void saveBrightness(View view){
int screenBrightness = BrightnessTools.getScreenBrightness(this);
T.showLong(this, "当前屏幕亮度为:"+screenBrightness);
BrightnessTools.saveBrightness(getContentResolver(), 255);
}
//开启关闭自动调节亮度
public void offAuto(View view){
boolean autoBrightness = BrightnessTools.isAutoBrightness(getContentResolver());
if (autoBrightness) {
T.showLong(this, "关闭自动调节亮度");
BrightnessTools.stopAutoBrightness(this);
}else {
T.showLong(this, "开启自动调节亮度");
BrightnessTools.startAutoBrightness(this);
}
}
阅读全文 »

Android极速开发之SD卡缓存目录

发表于 2016-08-27   |   分类于 Android , Android极速开发   |     |   阅读次数
  • 读取某个文件夹中的所有Apk文件路径并打开安装页面
  • 读取某文件夹下的所有apk文件
  • 获取SD卡跟目录中的某个文件
  • 弹出安装界面
  • 卸载apk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/**
*
* @author Javen
*
*/
public class SDKUtil {
private final static String TAG=SDKUtil.class.getSimpleName();
/**
* 读取某个文件夹中的所有Apk文件路径并打开安装页面
* @param context
* @param path
*/
public static void readApkAndStart(Context context,String path){
List<String> listpath = readAllApkForPath(context, path);
if (listpath!=null && listpath.size()>0) {
for (String string : listpath) {
SDKUtil.openInstallView(context, string);
}
}else {
L.e("xxxx-----", "readApkAndStart null。。。。。。。");
}
}
/**
* 读取某文件夹下的所有apk文件
* @param context
* @param path
* @return
*/
public static List<String> readAllApkForPath(Context context,String path){
List<String> fileNameList=new ArrayList<String>();
File dir;
if (Parameter.isDebug) {
dir = getSDir(context, path);
}else {
dir = getDiskCacheDir(context, path);
}
if (dir.isDirectory()) {
File[] files = dir.listFiles();
for (File file : files) {
String filePath = file.getAbsolutePath();
if (filePath.endsWith(".apk")) {
fileNameList.add(filePath);
}
}
return fileNameList;
}
return null;
}
/**
* 获取SD卡跟目录中的某个文件
* @param context
* @param uniqueName
* @return
*/
public static File getSDir(Context context, String uniqueName) {
boolean externalStorageAvailable = Environment
.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
String path = null;
if (externalStorageAvailable) {
path=Environment.getExternalStorageDirectory().getAbsolutePath();
}
return new File(path + File.separator + uniqueName);
}
/**
* 获取缓存地址
* @param context
* @param uniqueName
* @return
*/
public static File getDiskCacheDir(Context context, String uniqueName) {
boolean externalStorageAvailable = Environment
.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
String cachePath;
if (externalStorageAvailable) {
cachePath = context.getExternalCacheDir().getPath();
} else {
cachePath = context.getCacheDir().getPath();
}
L.i(TAG, cachePath);
return new File(cachePath + File.separator + uniqueName);
}
/**
* 弹出安装界面
* @param context
* @param pathString apk 路径
*/
public static void openInstallView(Context context,String pathString){
//启动安装界面
// Intent install = new Intent(Intent.ACTION_VIEW);
// install.setDataAndType(Uri.fromFile(new File(pathString)),
// "application/vnd.android.package-archive");
// install.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// context.startActivity(install);
ApkController.install(pathString, context);
}
/**
* 卸载apk
* @param context
* @param packageName
*/
public static void uninstallApk(Context context, String packageName) {
Uri uri = Uri.parse("package:" + packageName);
Intent intent = new Intent(Intent.ACTION_DELETE, uri);
context.startActivity(intent);
}
}
1…456…10
Javen

Javen

凡事皆有终结,因此,耐心是赢得成功的一种手段。

48 日志
16 分类
23 标签
Git 微博 博客 QQ
友情链接
  • Git教程
  • NextT
  • 友情链接
© 2015 - 2017 Javen
由 Hexo 强力驱动
主题 - NexT.Pisces
本站访客数人次 本站总访问量次