Skip to content

Commit

Permalink
适配 Android 11
Browse files Browse the repository at this point in the history
  • Loading branch information
getActivity committed Jun 29, 2020
1 parent 39fdd7d commit 4654e7b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#### 集成步骤

dependencies {
implementation 'com.hjq:toast:8.3'
implementation 'com.hjq:toast:8.5'
}

#### 初始化 Toast
Expand Down
Binary file modified ToastUtils.apk
Binary file not shown.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.hjq.toast.demo"
minSdkVersion 14
targetSdkVersion 28
versionCode 83
versionName "8.3"
versionCode 85
versionName "8.5"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -24,7 +24,7 @@ dependencies {
implementation project(':library')
implementation 'com.android.support:appcompat-v7:28.0.0'
// 标题栏:https://github.com/getActivity/TitleBar
implementation 'com.hjq:titlebar:6.0'
implementation 'com.hjq:titlebar:6.5'
// 悬浮窗:https://github.com/getActivity/XToast
implementation 'com.hjq:xtoast:5.5'
// 内存泄漏捕捉:https://github.com/square/leakcanary
Expand Down
6 changes: 3 additions & 3 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ android {
defaultConfig {
minSdkVersion 3
targetSdkVersion 26
versionCode 83
versionName "8.3"
versionCode 85
versionName "8.5"
}
}

publish {
userOrg = 'getactivity'
groupId = 'com.hjq'
artifactId = 'toast'
version = '8.3'
version = '8.5'
description = 'This is a very functional Toast'
website = "https://github.com/getActivity/ToastUtils"
}
Expand Down
6 changes: 5 additions & 1 deletion library/src/main/java/com/hjq/toast/ToastUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ public static void init(Application application, IToastStyle style) {

// 初始化吐司
if (areNotificationsEnabled(application)) {
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.N_MR1) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O + 4) {
// 适配 Android 11 无法使用自定义 Toast 的问题
// 官方文档:https://developer.android.google.cn/preview/features/toasts
setToast(new SupportToast(application));
} else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.N_MR1) {
// 解决 Android 7.1 上主线程被阻塞后吐司会报错的问题
setToast(new SafeToast(application));
} else {
Expand Down

0 comments on commit 4654e7b

Please sign in to comment.