Skip to content

Commit 077e24e

Browse files
committed
see 04/20 log
1 parent 99d2cf7 commit 077e24e

File tree

14 files changed

+62
-33
lines changed

14 files changed

+62
-33
lines changed

README-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
4343

44-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.13.14-brightgreen.svg
44+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.13.15-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

4747
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ If this project helps you a lot and you want to support the project's developmen
4141

4242
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
4343

44-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.13.14-brightgreen.svg
44+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.13.15-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

4747
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ dependencies {
5757
// LeakCanary
5858
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakcanary_version"
5959
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary_version"
60-
// implementation 'com.blankj:utilcode:1.13.14'
60+
// implementation 'com.blankj:utilcode:1.13.15'
6161
}
6262

6363

app/src/main/java/com/blankj/androidutilcode/UtilsApp.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
package com.blankj.androidutilcode;
22

33
import android.annotation.SuppressLint;
4-
import android.app.AlarmManager;
5-
import android.app.PendingIntent;
6-
import android.content.Context;
7-
import android.content.Intent;
84

95
import com.blankj.androidutilcode.base.BaseApplication;
10-
import com.blankj.utilcode.util.ActivityUtils;
6+
import com.blankj.utilcode.util.AppUtils;
117
import com.blankj.utilcode.util.CrashUtils;
128
import com.blankj.utilcode.util.LogUtils;
139
import com.squareup.leakcanary.LeakCanary;
@@ -75,23 +71,10 @@ private void initCrash() {
7571
@Override
7672
public void onCrash(String crashInfo, Throwable e) {
7773
LogUtils.e(crashInfo);
78-
restartApp();
74+
AppUtils.relaunchApp();
7975
}
8076
});
8177
}
82-
83-
private void restartApp() {
84-
Intent intent = new Intent();
85-
intent.setClassName("com.blankj.androidutilcode", "com.blankj.androidutilcode.MainActivity");
86-
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
87-
PendingIntent restartIntent = PendingIntent.getActivity(this, 0, intent, 0);
88-
AlarmManager manager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
89-
if (manager == null) return;
90-
manager.set(AlarmManager.RTC, System.currentTimeMillis() + 1, restartIntent);
91-
ActivityUtils.finishAllActivities();
92-
android.os.Process.killProcess(android.os.Process.myPid());
93-
System.exit(1);
94-
}
9578
}
9679

9780

app/src/main/java/com/blankj/androidutilcode/feature/core/app/AppActivity.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,10 @@ public void initView(Bundle savedInstanceState, View contentView) {
5151
findViewById(R.id.btn_uninstall_app).setOnClickListener(this);
5252
findViewById(R.id.btn_uninstall_app_silent).setOnClickListener(this);
5353
findViewById(R.id.btn_launch_app).setOnClickListener(this);
54+
findViewById(R.id.btn_relaunch_app).setOnClickListener(this);
5455
findViewById(R.id.btn_exit_app).setOnClickListener(this);
5556
findViewById(R.id.btn_launch_app_details_settings).setOnClickListener(this);
5657
TextView tvAboutApp = findViewById(R.id.tv_about_app);
57-
// "pkg name: " + getPackageName() +
58-
// "\napp name: " + getName() +
59-
// "\napp path: " + getPackagePath() +
60-
// "\napp v name: " + getVersionName() +
61-
// "\napp v code: " + getVersionCode() +
62-
// "\nis system: " + isSystem();
6358
tvAboutApp.setText(new SpanUtils()
6459
.appendLine("isAppRoot: " + AppUtils.isAppRoot())
6560
.appendLine("isAppDebug: " + AppUtils.isAppDebug())
@@ -136,6 +131,9 @@ public void onReleased() {
136131
case R.id.btn_launch_app:
137132
AppUtils.launchApp(this.getPackageName());
138133
break;
134+
case R.id.btn_relaunch_app:
135+
AppUtils.relaunchApp();
136+
break;
139137
case R.id.btn_launch_app_details_settings:
140138
AppUtils.launchAppDetailsSettings();
141139
break;

app/src/main/java/com/blankj/androidutilcode/feature/core/device/DeviceActivity.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import com.blankj.utilcode.util.DeviceUtils;
1313
import com.blankj.utilcode.util.SpanUtils;
1414

15+
import java.util.Arrays;
16+
1517
/**
1618
* <pre>
1719
* author: Blankj
@@ -53,7 +55,8 @@ public void initView(Bundle savedInstanceState, View contentView) {
5355
.appendLine("getAndroidID: " + DeviceUtils.getAndroidID())
5456
.appendLine("getMacAddress: " + DeviceUtils.getMacAddress())
5557
.appendLine("getManufacturer: " + DeviceUtils.getManufacturer())
56-
.append("getModel: " + DeviceUtils.getModel())
58+
.appendLine("getModel: " + DeviceUtils.getModel())
59+
.append("getABIs: " + Arrays.asList(DeviceUtils.getABIs()))
5760
.create()
5861
);
5962
}

app/src/main/res_core/layout/activity_app.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@
4848
android:layout_height="wrap_content"
4949
android:text="@string/app_launch" />
5050

51+
<Button
52+
android:id="@+id/btn_relaunch_app"
53+
style="@style/WideBtnStyle"
54+
android:layout_width="match_parent"
55+
android:layout_height="wrap_content"
56+
android:text="@string/app_relaunch" />
57+
5158
<Button
5259
android:id="@+id/btn_launch_app_details_settings"
5360
style="@style/WideBtnStyle"

app/src/main/res_core/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
<string name="uninstall_successfully">Uninstall successfully</string>
6767
<string name="uninstall_unsuccessfully">Uninstall unsuccessfully</string>
6868
<string name="app_launch">Launch App</string>
69+
<string name="app_relaunch">Relaunch App</string>
6970
<string name="app_launch_details_settings">Launch App Details Settings</string>
7071
<string name="app_exit">Exit App</string>
7172

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ ext {
3333
min_sdk_version = 14
3434
target_sdk_version = 27
3535

36-
version_code = 1_013_014
37-
version_name = '1.13.14'// E.g 1.9.72 => 1,009,072
36+
version_code = 1_013_015
37+
version_name = '1.13.15'// E.g 1.9.72 => 1,009,072
3838

3939
// App dependencies
4040
support_version = '27.1.0'

update_log.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* 18/04/21 新增 AppUtils#relaunchApp、DeviceUtils#getABIs,发布 1.13.15 版本
12
* 18/04/20 新增 BarUtils#setNavBarColor、BarUtils#getNavBarColor
23
* 18/04/19 新增 Process#isMainProcess、Process#getCurrentProcessName,发布 1.13.14 版本
34
* 18/04/18 修复 LogUtils 头部空指针异常,SPUtils、CacheUtils 存储空值异常,发布 1.13.13 版本

utilcode/README-CN.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gradle:
44
```groovy
5-
implementation 'com.blankj:utilcode:1.13.14'
5+
implementation 'com.blankj:utilcode:1.13.15'
66
```
77

88

@@ -54,6 +54,7 @@ isAppDebug : 判断 App 是否是 Debug 版本
5454
isAppSystem : 判断 App 是否是系统应用
5555
isAppForeground : 判断 App 是否处于前台
5656
launchApp : 打开 App
57+
relaunchApp : 重启 App
5758
launchAppDetailsSettings: 打开 App 具体设置
5859
exitApp : 关闭应用
5960
getAppIcon : 获取 App 图标
@@ -161,6 +162,7 @@ getAndroidID : 获取设备 AndroidID
161162
getMacAddress : 获取设备 MAC 地址
162163
getManufacturer : 获取设备厂商
163164
getModel : 获取设备型号
165+
getABIs : 获取设备 ABIs
164166
shutdown : 关机
165167
reboot : 重启
166168
reboot2Recovery : 重启到 recovery

utilcode/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gradle:
44
```groovy
5-
implementation 'com.blankj:utilcode:1.13.14'
5+
implementation 'com.blankj:utilcode:1.13.15'
66
```
77

88

@@ -54,6 +54,7 @@ isAppDebug
5454
isAppSystem
5555
isAppForeground
5656
launchApp
57+
relaunchApp
5758
launchAppDetailsSettings
5859
exitApp
5960
getAppIcon
@@ -161,6 +162,7 @@ getAndroidID
161162
getMacAddress
162163
getManufacturer
163164
getModel
165+
getABIs
164166
shutdown
165167
reboot
166168
reboot2Recovery

utilcode/src/main/java/com/blankj/utilcode/util/AppUtils.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.annotation.SuppressLint;
44
import android.app.Activity;
5+
import android.content.ComponentName;
56
import android.content.Intent;
67
import android.content.pm.ApplicationInfo;
78
import android.content.pm.PackageInfo;
@@ -370,6 +371,19 @@ public static void launchApp(final Activity activity,
370371
activity.startActivityForResult(IntentUtils.getLaunchAppIntent(packageName), requestCode);
371372
}
372373

374+
/**
375+
* Relaunch the application.
376+
*/
377+
public static void relaunchApp() {
378+
PackageManager packageManager = Utils.getApp().getPackageManager();
379+
Intent intent = packageManager.getLaunchIntentForPackage(Utils.getApp().getPackageName());
380+
if (intent == null) return;
381+
ComponentName componentName = intent.getComponent();
382+
Intent mainIntent = Intent.makeRestartActivityTask(componentName);
383+
Utils.getApp().startActivity(mainIntent);
384+
System.exit(0);
385+
}
386+
373387
/**
374388
* Launch the application's details settings.
375389
*/

utilcode/src/main/java/com/blankj/utilcode/util/DeviceUtils.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import android.os.PowerManager;
1010
import android.provider.Settings;
1111
import android.support.annotation.RequiresPermission;
12+
import android.text.TextUtils;
1213

1314
import java.io.File;
1415
import java.net.InetAddress;
@@ -233,6 +234,23 @@ public static String getModel() {
233234
return model;
234235
}
235236

237+
/**
238+
* Return an ordered list of ABIs supported by this device. The most preferred ABI is the first
239+
* element in the list.
240+
*
241+
* @return an ordered list of ABIs supported by this device
242+
*/
243+
public static String[] getABIs() {
244+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
245+
return Build.SUPPORTED_ABIS;
246+
} else {
247+
if (!TextUtils.isEmpty(Build.CPU_ABI2)) {
248+
return new String[]{Build.CPU_ABI, Build.CPU_ABI2};
249+
}
250+
return new String[]{Build.CPU_ABI};
251+
}
252+
}
253+
236254
/**
237255
* Shutdown the device
238256
* <p>Requires root permission

0 commit comments

Comments
 (0)