Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xiaoxuan_i809
AndroidUtilCode
提交
077e24ec
A
AndroidUtilCode
项目概览
xiaoxuan_i809
/
AndroidUtilCode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
AndroidUtilCode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
077e24ec
编写于
4月 20, 2018
作者:
B
Blankj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
see 04/20 log
上级
99d2cf7a
变更
14
显示空白变更内容
内联
并排
Showing
14 changed file
with
62 addition
and
33 deletion
+62
-33
README-CN.md
README-CN.md
+1
-1
README.md
README.md
+1
-1
app/build.gradle
app/build.gradle
+1
-1
app/src/main/java/com/blankj/androidutilcode/UtilsApp.java
app/src/main/java/com/blankj/androidutilcode/UtilsApp.java
+2
-19
app/src/main/java/com/blankj/androidutilcode/feature/core/app/AppActivity.java
.../blankj/androidutilcode/feature/core/app/AppActivity.java
+4
-6
app/src/main/java/com/blankj/androidutilcode/feature/core/device/DeviceActivity.java
...j/androidutilcode/feature/core/device/DeviceActivity.java
+4
-1
app/src/main/res_core/layout/activity_app.xml
app/src/main/res_core/layout/activity_app.xml
+7
-0
app/src/main/res_core/values/strings.xml
app/src/main/res_core/values/strings.xml
+1
-0
build.gradle
build.gradle
+2
-2
update_log.md
update_log.md
+1
-0
utilcode/README-CN.md
utilcode/README-CN.md
+3
-1
utilcode/README.md
utilcode/README.md
+3
-1
utilcode/src/main/java/com/blankj/utilcode/util/AppUtils.java
...code/src/main/java/com/blankj/utilcode/util/AppUtils.java
+14
-0
utilcode/src/main/java/com/blankj/utilcode/util/DeviceUtils.java
...e/src/main/java/com/blankj/utilcode/util/DeviceUtils.java
+18
-0
未找到文件。
README-CN.md
浏览文件 @
077e24ec
...
...
@@ -41,7 +41,7 @@
[
logo
]:
https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
[
aucsvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.13.1
4
-brightgreen.svg
[
aucsvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.13.1
5
-brightgreen.svg
[
auc
]:
https://github.com/Blankj/AndroidUtilCode
[
apisvg
]:
https://img.shields.io/badge/API-14+-brightgreen.svg
...
...
README.md
浏览文件 @
077e24ec
...
...
@@ -41,7 +41,7 @@ If this project helps you a lot and you want to support the project's developmen
[
logo
]:
https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
[
aucsvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.13.1
4
-brightgreen.svg
[
aucsvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.13.1
5
-brightgreen.svg
[
auc
]:
https://github.com/Blankj/AndroidUtilCode
[
apisvg
]:
https://img.shields.io/badge/API-14+-brightgreen.svg
...
...
app/build.gradle
浏览文件 @
077e24ec
...
...
@@ -57,7 +57,7 @@ dependencies {
// LeakCanary
debugImplementation
"com.squareup.leakcanary:leakcanary-android:$leakcanary_version"
releaseImplementation
"com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary_version"
// implementation 'com.blankj:utilcode:1.13.1
4
'
// implementation 'com.blankj:utilcode:1.13.1
5
'
}
app/src/main/java/com/blankj/androidutilcode/UtilsApp.java
浏览文件 @
077e24ec
package
com.blankj.androidutilcode
;
import
android.annotation.SuppressLint
;
import
android.app.AlarmManager
;
import
android.app.PendingIntent
;
import
android.content.Context
;
import
android.content.Intent
;
import
com.blankj.androidutilcode.base.BaseApplication
;
import
com.blankj.utilcode.util.A
ctivity
Utils
;
import
com.blankj.utilcode.util.A
pp
Utils
;
import
com.blankj.utilcode.util.CrashUtils
;
import
com.blankj.utilcode.util.LogUtils
;
import
com.squareup.leakcanary.LeakCanary
;
...
...
@@ -75,23 +71,10 @@ public class UtilsApp extends BaseApplication {
@Override
public
void
onCrash
(
String
crashInfo
,
Throwable
e
)
{
LogUtils
.
e
(
crashInfo
);
restart
App
();
AppUtils
.
relaunch
App
();
}
});
}
private
void
restartApp
()
{
Intent
intent
=
new
Intent
();
intent
.
setClassName
(
"com.blankj.androidutilcode"
,
"com.blankj.androidutilcode.MainActivity"
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
PendingIntent
restartIntent
=
PendingIntent
.
getActivity
(
this
,
0
,
intent
,
0
);
AlarmManager
manager
=
(
AlarmManager
)
this
.
getSystemService
(
Context
.
ALARM_SERVICE
);
if
(
manager
==
null
)
return
;
manager
.
set
(
AlarmManager
.
RTC
,
System
.
currentTimeMillis
()
+
1
,
restartIntent
);
ActivityUtils
.
finishAllActivities
();
android
.
os
.
Process
.
killProcess
(
android
.
os
.
Process
.
myPid
());
System
.
exit
(
1
);
}
}
app/src/main/java/com/blankj/androidutilcode/feature/core/app/AppActivity.java
浏览文件 @
077e24ec
...
...
@@ -51,15 +51,10 @@ public class AppActivity extends BaseBackActivity {
findViewById
(
R
.
id
.
btn_uninstall_app
).
setOnClickListener
(
this
);
findViewById
(
R
.
id
.
btn_uninstall_app_silent
).
setOnClickListener
(
this
);
findViewById
(
R
.
id
.
btn_launch_app
).
setOnClickListener
(
this
);
findViewById
(
R
.
id
.
btn_relaunch_app
).
setOnClickListener
(
this
);
findViewById
(
R
.
id
.
btn_exit_app
).
setOnClickListener
(
this
);
findViewById
(
R
.
id
.
btn_launch_app_details_settings
).
setOnClickListener
(
this
);
TextView
tvAboutApp
=
findViewById
(
R
.
id
.
tv_about_app
);
// "pkg name: " + getPackageName() +
// "\napp name: " + getName() +
// "\napp path: " + getPackagePath() +
// "\napp v name: " + getVersionName() +
// "\napp v code: " + getVersionCode() +
// "\nis system: " + isSystem();
tvAboutApp
.
setText
(
new
SpanUtils
()
.
appendLine
(
"isAppRoot: "
+
AppUtils
.
isAppRoot
())
.
appendLine
(
"isAppDebug: "
+
AppUtils
.
isAppDebug
())
...
...
@@ -136,6 +131,9 @@ public class AppActivity extends BaseBackActivity {
case
R
.
id
.
btn_launch_app
:
AppUtils
.
launchApp
(
this
.
getPackageName
());
break
;
case
R
.
id
.
btn_relaunch_app
:
AppUtils
.
relaunchApp
();
break
;
case
R
.
id
.
btn_launch_app_details_settings
:
AppUtils
.
launchAppDetailsSettings
();
break
;
...
...
app/src/main/java/com/blankj/androidutilcode/feature/core/device/DeviceActivity.java
浏览文件 @
077e24ec
...
...
@@ -12,6 +12,8 @@ import com.blankj.androidutilcode.base.BaseBackActivity;
import
com.blankj.utilcode.util.DeviceUtils
;
import
com.blankj.utilcode.util.SpanUtils
;
import
java.util.Arrays
;
/**
* <pre>
* author: Blankj
...
...
@@ -53,7 +55,8 @@ public class DeviceActivity extends BaseBackActivity {
.
appendLine
(
"getAndroidID: "
+
DeviceUtils
.
getAndroidID
())
.
appendLine
(
"getMacAddress: "
+
DeviceUtils
.
getMacAddress
())
.
appendLine
(
"getManufacturer: "
+
DeviceUtils
.
getManufacturer
())
.
append
(
"getModel: "
+
DeviceUtils
.
getModel
())
.
appendLine
(
"getModel: "
+
DeviceUtils
.
getModel
())
.
append
(
"getABIs: "
+
Arrays
.
asList
(
DeviceUtils
.
getABIs
()))
.
create
()
);
}
...
...
app/src/main/res_core/layout/activity_app.xml
浏览文件 @
077e24ec
...
...
@@ -48,6 +48,13 @@
android:layout_height=
"wrap_content"
android:text=
"@string/app_launch"
/>
<Button
android:id=
"@+id/btn_relaunch_app"
style=
"@style/WideBtnStyle"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/app_relaunch"
/>
<Button
android:id=
"@+id/btn_launch_app_details_settings"
style=
"@style/WideBtnStyle"
...
...
app/src/main/res_core/values/strings.xml
浏览文件 @
077e24ec
...
...
@@ -66,6 +66,7 @@
<string
name=
"uninstall_successfully"
>
Uninstall successfully
</string>
<string
name=
"uninstall_unsuccessfully"
>
Uninstall unsuccessfully
</string>
<string
name=
"app_launch"
>
Launch App
</string>
<string
name=
"app_relaunch"
>
Relaunch App
</string>
<string
name=
"app_launch_details_settings"
>
Launch App Details Settings
</string>
<string
name=
"app_exit"
>
Exit App
</string>
...
...
build.gradle
浏览文件 @
077e24ec
...
...
@@ -33,8 +33,8 @@ ext {
min_sdk_version
=
14
target_sdk_version
=
27
version_code
=
1
_013_01
4
version_name
=
'1.13.1
4
'
// E.g 1.9.72 => 1,009,072
version_code
=
1
_013_01
5
version_name
=
'1.13.1
5
'
// E.g 1.9.72 => 1,009,072
// App dependencies
support_version
=
'27.1.0'
...
...
update_log.md
浏览文件 @
077e24ec
*
18/04/21 新增 AppUtils#relaunchApp、DeviceUtils#getABIs,发布 1.13.15 版本
*
18/04/20 新增 BarUtils#setNavBarColor、BarUtils#getNavBarColor
*
18/04/19 新增 Process#isMainProcess、Process#getCurrentProcessName,发布 1.13.14 版本
*
18/04/18 修复 LogUtils 头部空指针异常,SPUtils、CacheUtils 存储空值异常,发布 1.13.13 版本
...
...
utilcode/README-CN.md
浏览文件 @
077e24ec
...
...
@@ -2,7 +2,7 @@
Gradle:
```
groovy
implementation
'com.blankj:utilcode:1.13.1
4
'
implementation
'com.blankj:utilcode:1.13.1
5
'
```
...
...
@@ -54,6 +54,7 @@ isAppDebug : 判断 App 是否是 Debug 版本
isAppSystem : 判断 App 是否是系统应用
isAppForeground : 判断 App 是否处于前台
launchApp : 打开 App
relaunchApp : 重启 App
launchAppDetailsSettings: 打开 App 具体设置
exitApp : 关闭应用
getAppIcon : 获取 App 图标
...
...
@@ -161,6 +162,7 @@ getAndroidID : 获取设备 AndroidID
getMacAddress : 获取设备 MAC 地址
getManufacturer : 获取设备厂商
getModel : 获取设备型号
getABIs : 获取设备 ABIs
shutdown : 关机
reboot : 重启
reboot2Recovery : 重启到 recovery
...
...
utilcode/README.md
浏览文件 @
077e24ec
...
...
@@ -2,7 +2,7 @@
Gradle:
```
groovy
implementation
'com.blankj:utilcode:1.13.1
4
'
implementation
'com.blankj:utilcode:1.13.1
5
'
```
...
...
@@ -54,6 +54,7 @@ isAppDebug
isAppSystem
isAppForeground
launchApp
relaunchApp
launchAppDetailsSettings
exitApp
getAppIcon
...
...
@@ -161,6 +162,7 @@ getAndroidID
getMacAddress
getManufacturer
getModel
getABIs
shutdown
reboot
reboot2Recovery
...
...
utilcode/src/main/java/com/blankj/utilcode/util/AppUtils.java
浏览文件 @
077e24ec
...
...
@@ -2,6 +2,7 @@ package com.blankj.utilcode.util;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.content.ComponentName
;
import
android.content.Intent
;
import
android.content.pm.ApplicationInfo
;
import
android.content.pm.PackageInfo
;
...
...
@@ -370,6 +371,19 @@ public final class AppUtils {
activity
.
startActivityForResult
(
IntentUtils
.
getLaunchAppIntent
(
packageName
),
requestCode
);
}
/**
* Relaunch the application.
*/
public
static
void
relaunchApp
()
{
PackageManager
packageManager
=
Utils
.
getApp
().
getPackageManager
();
Intent
intent
=
packageManager
.
getLaunchIntentForPackage
(
Utils
.
getApp
().
getPackageName
());
if
(
intent
==
null
)
return
;
ComponentName
componentName
=
intent
.
getComponent
();
Intent
mainIntent
=
Intent
.
makeRestartActivityTask
(
componentName
);
Utils
.
getApp
().
startActivity
(
mainIntent
);
System
.
exit
(
0
);
}
/**
* Launch the application's details settings.
*/
...
...
utilcode/src/main/java/com/blankj/utilcode/util/DeviceUtils.java
浏览文件 @
077e24ec
...
...
@@ -9,6 +9,7 @@ import android.os.Build;
import
android.os.PowerManager
;
import
android.provider.Settings
;
import
android.support.annotation.RequiresPermission
;
import
android.text.TextUtils
;
import
java.io.File
;
import
java.net.InetAddress
;
...
...
@@ -233,6 +234,23 @@ public final class DeviceUtils {
return
model
;
}
/**
* Return an ordered list of ABIs supported by this device. The most preferred ABI is the first
* element in the list.
*
* @return an ordered list of ABIs supported by this device
*/
public
static
String
[]
getABIs
()
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
return
Build
.
SUPPORTED_ABIS
;
}
else
{
if
(!
TextUtils
.
isEmpty
(
Build
.
CPU_ABI2
))
{
return
new
String
[]{
Build
.
CPU_ABI
,
Build
.
CPU_ABI2
};
}
return
new
String
[]{
Build
.
CPU_ABI
};
}
}
/**
* Shutdown the device
* <p>Requires root permission
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录