标签: android-12

如何检查Android 12 API级别?

我正在尝试使用以下代码检查 android 12 API 级别。

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
{
     // Do something for Android 12 and above versions 
}
else
{
    // Do something for phones running an SDK before Android 12
}
Run Code Online (Sandbox Code Playgroud)

但在 android 12 beta 设备中运行应用程序时始终执行其他部分。这是检查 android 12 beta 版本的另一种方法吗?

android-studio android-api-levels android-12

4
推荐指数
1
解决办法
8061
查看次数

SparseArray 错误:调用需要 API 级别 S

将compileSdkVersion增加到31(Android 12)后,执行lint检查时,出现以下问题:

错误:调用需要 API 级别 S(当前最小值为 23):android.util.SparseArray#set [NewApi]

增加此值后是否有人遇到类似的问题,为什么会发生?

android lint sparse-matrix kotlin android-12

4
推荐指数
1
解决办法
1867
查看次数

android 12 最新版本:模拟器构建未针对 android-12.0.0_r2 aosp 版本运行

我已经在本地构建了 android-12.0.0_r2 并尝试运行它,但它给出了错误。

构建步骤:

$源构建/envsetup.sh

$ 午餐 aosp_x86_64-eng

$ 使-j32

跑步:

$模拟器&

错误:out/target/product/generic_arm64/userdata-qemu.img':没有这样的文件或目录

即使从 android_11 复制此图像后,我也可以看到模拟器正在启动,但它处于挂起状态。任何想法 ?

谢谢。

android android-emulator android-source android-12

4
推荐指数
1
解决办法
1616
查看次数

由于三星设置应用程序崩溃,用户的 Android 12 深层链接关联失败

我的目标是 android 12 并使用此用户关联方法使我的深层链接由应用程序处理。

我显示一个带有 [转到设置] 按钮的对话框,要求从应用程序设置添加支持的链接。在 [转到设置] 上单击我运行此代码

val intent = Intent(Settings.ACTION_APP_OPEN_BY_DEFAULT_SETTINGS,
            Uri.parse("package:${context.packageName}"))
        startActivity(context, intent)
Run Code Online (Sandbox Code Playgroud)

这会在设备设置应用程序中打开我的应用程序[设置为默认]部分,用户可以在其中启用支持的网址。 在此输入图像描述

这适用于大多数设备。但对于三星 Galaxy s21(也许是所有配备 Android 12 的三星)设备,应用程序关闭时没有崩溃日志。

我发现崩溃发生在设备设置应用程序中,这是日志。

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference
    at com.android.settings.applications.intentpicker.AppLaunchSettings.onCreate(AppLaunchSettings.java:142)
    at androidx.fragment.app.Fragment.performCreate(Fragment.java:2976)
    at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:475)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:278)
    at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2189)
    at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2100)
    at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:2002)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3138)
    at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:3072)
    at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:251)
    at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:501)
    at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:246)
    at com.samsung.android.settings.core.SecMultiPaneActivity.onStart(SecMultiPaneActivity.java:198)
    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1455)
    at android.app.Activity.performStart(Activity.java:8307)
    at android.app.ActivityThread.handleStartActivity(ActivityThread.java:4047)
    at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
    at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
    at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
    at …
Run Code Online (Sandbox Code Playgroud)

android deep-linking android-12

4
推荐指数
1
解决办法
2491
查看次数

设备所有者 QR 停止在 Android12 设备上工作,收到“无法设置设备”消息

由于某种原因,用于以设备所有者身份安装我们的应用程序的二维码在 Android12 设备上停止运行(相同的二维码在以前的 Android 版本上完美运行)。

我们收到的错误消息是:

Can't set up device
Contact your IT admin for help
Run Code Online (Sandbox Code Playgroud)

这是二维码的 JSON

{
  "android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION": "https://someurlthatworkforsure",
  "android.app.extra.PROVISIONING_SKIP_ENCRYPTION": true,
  "android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM": "validCheckSumThatWasTestedAndDoesWorkOnAndroidPriodTo12",
  "android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME": "com.brand.name/com.brand.some.SomeClass"
}
Run Code Online (Sandbox Code Playgroud)

我进行了一些谷歌搜索,但没有发现我们的二维码有什么问题,

我也尝试将 PROVISIONING_SKIP_ENCRYPTION 设置为 false 并将其删除,结果是相同的。

CHECKSUM 是有效的,如果我弄乱它会引发不同的错误......

提前致谢。

android device-policy-manager device-owner android-12

4
推荐指数
1
解决办法
1261
查看次数

Firebase Cloud Messaging 在 Android 12+ 上无法对 SDK 31+ 进行身份验证

我为我的应用程序设置了 FCM。它非常适合运行 Android 11 及更低版本的设备。但对于 Android 12 及更高版本的设备,我无法通过使用接收令牌

FirebaseMessaging.getInstance().token.addOnCompleteListener {
            ...
        } 
Run Code Online (Sandbox Code Playgroud)

我收到错误:java.io.IOException: java.util.concurrent.ExecutionException: java.io.IOException: AUTHENTICATION_FAILED而不是令牌

显现

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.boltic28.learnmultiplying">

    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.LearnMultiplying"
        tools:targetApi="31">
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <service
            android:name=".services.firebase.AppFirebaseMessagingService"
            android:exported="false">

            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

        <meta-data
            android:name="com.google.firebase.messaging.default_notification_channel_id"
            android:value="@string/default_notification_channel_id" />

    </application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

应用程序:

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'com.google.gms.google-services'
}

android {
    compileSdk 33

    defaultConfig {
        applicationId "com.boltic28.learnmultiplying" …
Run Code Online (Sandbox Code Playgroud)

firebase firebase-authentication firebase-cloud-messaging android-12 android-13

4
推荐指数
1
解决办法
2734
查看次数

Flutter Android 13 启动画面看起来不正确

我一直在尝试向我的应用程序添加启动画面,但我尝试过的每个配置都没有产生良好的结果。

在此输入图像描述

这是我尝试过的最后一次也是最简单的尝试。我正在运行 Android 13 的三星 Galaxy S21 FE 上进行测试。我还在运行 Android 13 的 Pixel 6 上使用 Android Studio 模拟器进行了测试,结果相同。我使用运行 Android 11 的 Nexus 5X 模拟器进行测试,没有出现两种尺寸图像问题。我用来flutter_native_splash: ^2.2.18生成启动画面。这是我的 flutter_native_splash.yaml 配置:

flutter_native_splash:
  color: "#eeeeee"
  image: assets/launcher/launcher.png

  android_12:
    image: assets/launcher/launcher_android_12.png
    color: "#eeeeee"

  web: false
Run Code Online (Sandbox Code Playgroud)

这是两张图片。

launcher_android_12.png

在此输入图像描述

启动器.png

在此输入图像描述

我尝试在常规配置和 android_12 配置上使用这两个图像,但它们都没有产生更好的结果。我希望看到一个连续的闪屏,而不是一个大图像后面跟着一个较小的图像。

android splash-screen flutter android-12 android-13

4
推荐指数
1
解决办法
4501
查看次数

Android 12 - 通知蹦床限制

由于 android 12, 通知蹦床限制导致我的项目出现一个大问题。我开发了一个 SDK,用于显示本地通知。我的问题是我使用通知是为了显示横幅或在应用程序内打开 Web 视图。对于通知蹦床限制,我需要使用待定意图指定通知单击事件。我的问题是,从 SDK 端,我找到应用程序包 ID 并启动 MainActivity,每次我点击通知时,即使应用程序位于后台或前台,应用程序也会重新启动。

我需要了解以下信息

  1. 我如何知道应用程序何时在前台或后台处于活动状态
  2. 如果存在需要知道哪个活动位于堆栈顶部

您是否遇到过相同或类似的问题?你是怎么解决的?任何帮助将不胜感激。谢谢你!

sdk android push-notification android-notifications android-12

3
推荐指数
1
解决办法
4547
查看次数

启动画面 API 不显示图标

我们目前正在通过新的 Splashscreen API 实现启动屏幕。我们正在遵循迁移指南。背景颜色设置正确(通过windowSplashScreenBackground),但图标在模拟器和物理设备上均不可见。

构建.gradle

android {
    compileSdkVersion 31
    ...
}

dependencies {
    implementation "androidx.core:core-splashscreen:1.0.0-alpha01"
    ...
}
Run Code Online (Sandbox Code Playgroud)

值-v31/themes.xml

<style name="AppTheme" parent="Theme.SplashScreen">
    <item name="postSplashScreenTheme">@style/AppThemeCompat</item>
    <item name="windowSplashScreenBackground">@android:color/black</item>
    <item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher</item>
    <item name="windowSplashScreenAnimationDuration">200</item>
</style>
Run Code Online (Sandbox Code Playgroud)

AndroidManifest.xml

<application
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme">
    ...
</application>
Run Code Online (Sandbox Code Playgroud)

MainActivity.kt

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen()
    ...
}
Run Code Online (Sandbox Code Playgroud)

android androidx android-12

3
推荐指数
1
解决办法
987
查看次数

Android 12 上的 flutter WebView 中软键盘停止工作

我在生产中有一些 flutter 应用程序,其中 webview 停止工作。无论单击哪种输入字段,webview_flutter都无法在 Android 12 (API 31) 上显示(软)键盘。在 Android 11 和 12 之间切换时,可以使用 Android 模拟器轻松重现该错误。在 Android 12 上,该错误会失败,并出现如下异常:

[        ] V/InputMethodManager(10400): b/117267690: Display ID mismatch found. ViewRootImpl displayId=1 InputMethodManager displayId=0. Use the right InputMethodManager instance to avoid performance overhead.
[        ] V/InputMethodManager(10400): java.lang.Throwable
[        ] V/InputMethodManager(10400):     at android.view.inputmethod.InputMethodManager.getFallbackInputMethodManagerIfNecessary(InputMethodManager.java:549)
[        ] V/InputMethodManager(10400):     at android.view.inputmethod.InputMethodManager.restartInput(InputMethodManager.java:1843)
[        ] V/InputMethodManager(10400):     at org.chromium.content.browser.input.ImeAdapterImpl.H(chromium-TrichromeWebViewGoogle6432.apk-stable-447211487:4)
[        ] V/InputMethodManager(10400):     at org.chromium.content.browser.input.ImeAdapterImpl.updateState(chromium-TrichromeWebViewGoogle6432.apk-stable-447211487:30)
[        ] V/InputMethodManager(10400):     at android.os.MessageQueue.nativePollOnce(Native Method)
[        ] V/InputMethodManager(10400):     at android.os.MessageQueue.next(MessageQueue.java:335)
[        ] …
Run Code Online (Sandbox Code Playgroud)

android webview flutter android-12

3
推荐指数
1
解决办法
6379
查看次数