我有一台 android 版本 10 的设备。
另外,我有一个带有 API 22 的模拟器
这是我的 build.gradle(:app) 文件的一部分:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
android {
dataBinding {
enabled = true
}
compileSdkVersion 'android-R'
defaultConfig {
applicationId "com.example.android.sOnline"
minSdkVersion 17
targetSdkVersion 'R'
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
// android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true
}
}
Run Code Online (Sandbox Code Playgroud)
它只是不适用于“android-R”
感谢你们对我的帮助 :)
我的应用程序加载位于getFilesDir()via下的本地 html 文件WebView#loadUrl()。
之前targetSdkVersion = 29,下面的代码正在运行。
copyAssetsFile(this, "sample.html", getFilesDir().getAbsolutePath());
webView.getSettings().setJavaScriptEnabled(true);
String url = "file://" + getFilesDir().getAbsolutePath() + "/sample.html";
webView.loadUrl(url);
}
private static void copyAssetsFile(Context context, String fileName, String directoryPath) {
try {
InputStream inputStream = context.getResources().getAssets().open(fileName);
FileOutputStream fileOutputStream = new FileOutputStream(
new File(directoryPath, fileName), false);
byte[] buffer = new byte[1024];
int length = 0;
while ((length = inputStream.read(buffer)) >= 0) {
fileOutputStream.write(buffer, 0, length);
}
fileOutputStream.close();
inputStream.close();
Run Code Online (Sandbox Code Playgroud)
完整示例在这里。
但是,它在更改后不起作用targetSdkVersion = 30 …
我的应用开始在 Android 11 设备上崩溃,并显示以下错误消息“您应用的 AndroidManifest.xml 中的元数据标记没有正确的值。预期为 12451000,但发现为 4323000”。我知道这些问题,并且我已经在清单文件中定义了正确的值,如下所示:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
Run Code Online (Sandbox Code Playgroud)
如果我按照 google_play_services_version 我可以找到预期值
<integer name="google_play_services_version">12451000</integer>
Run Code Online (Sandbox Code Playgroud)
在 firebase 分析的帮助下,我可以确认它仅在 Android 11 设备上发生。

到目前为止,从各种 SO 帖子中,我尝试了以下内容:
1- 将所有使用的播放服务和 Firebase 依赖项更新到最新的可用版本。
2- 使用的工具:替换为 build clean 过程,在元数据标签中,对于 app 模块和磨损模块,如下所示:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"
tools:replace="android:value" />
Run Code Online (Sandbox Code Playgroud)
3- 检查@integer/google_play_services_version 中所有使用的第 3 部分库/SDK 的清单文件,但所有文件都重定向到预期值,即 12451000。
以下是 build.gradle 文件: A- build.gradle {:app}-
apply from: '../release-config.gradle'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'android-release-plugin'
apply plugin: 'testfairy'
apply from: …Run Code Online (Sandbox Code Playgroud) android gradle android-manifest google-play-services android-11
我有自定义声音的推送通知,直到 android 10。从 Android 11 开始,当通知显示为下拉样式时,附加到通知通道的声音停止播放。当它显示为全屏活动时,它会起作用。
这是如何创建通知通道的示例源代码
private void createNotificationChannel() {
// Create the NotificationChannel, but only on API 26+ because
// the NotificationChannel class is new and not in the support library
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
String channelId = "media_playback_channel_v_01_1_sound"
String channelName = "Channel High"
NotificationChannel channel = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_HIGH);
channel.setDescription("My custom sound");
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
AudioAttributes.Builder builder = new AudioAttributes.Builder();
builder.setUsage(AudioAttributes.USAGE_NOTIFICATION);
String basePath = ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + getPackageName() + "/" + R.raw.alarm_sound);
Uri alarmSound = Uri.parse(basePath); …Run Code Online (Sandbox Code Playgroud) 我们使用 Wifimanger getConnectionInfo() 方法来获取连接的 wifi 的 SSID 和 BBSID。但从 Andorid API level 31 开始,Android 已弃用 getConnectionInfo() 方法。
他们提供的使用 getTransportInfo() 的解决方案需要最低 Android 级别 29,这是我们无法确定的目标,因为我们 20% 的用户仍然使用低于 29 的 Android API 级别。
有人可以帮助使用替代方法来连接 wifi。
https://developer.android.com/reference/android/net/wifi/WifiManager#getConnectionInfo()
当您ACTION_OPEN_DOCUMENT_TREE在 Android 11 中选择存储文件的路径的权限时,默认的 Android 内容管理器默认会在最近使用的路径上打开,并且由于某种原因“使用此文件夹”按钮根本不会出现,即使此路径是可访问路径,除非用户手动移动路径以转到合适的位置(或者返回默认打开的路径,如果这是可选位置,则移动到目录)。
例如,假设用户使用的最新路径是Documents。当我要求用户选择允许应用程序保存文件的路径时,
Intent i = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
i.addCategory(Intent.CATEGORY_DEFAULT);
Run Code Online (Sandbox Code Playgroud)
这就是出现的情况:
正如您所看到的,没有“使用此文件夹”蓝色按钮。
现在,如果用户从此处选择超级文件夹路径并在文档中再次输入,这就是他所看到的:
现在“使用此文件夹”按钮可用。
这是完全没有意义的,而且对用户体验来说非常糟糕,许多用户最终肯定会感到烦恼和困惑地卸载该应用程序。
难道我做错了什么?是否可以向意图传递一些提示,以便直接在所有 Android 设备存储(例如DocumentsACTION_OPEN_DOCUMENT_TREE )中可用的特定路径中打开内容管理器视图,并在打开选择器时使用“使用此文件夹”按钮?
我的操作系统是 PixysOS - Android 11 当我这样做时
mount -o rw,remount /system
Run Code Online (Sandbox Code Playgroud)
它失败了——
mount: '/system' not in /proc/mounts
Run Code Online (Sandbox Code Playgroud)
但通常它是有效的。我也在android 9中测试过
Android 11 中引入了范围存储。根据文档,应使用保存非媒体文件(如 PDF)的存储访问框架。因此,使用存储访问框架的用户需要使用系统文件选择器选择位置来保存非媒体文件(PDF)。但是如果您在 Android 11 上使用 Whatsapp 应用程序并尝试保存 PDF 文件,它永远不会要求用户选择位置。默认情况下,它将保存 pdf 文件到外部文档目录。我想在我的应用程序中复制相同的行为。有人可以在这里指导我吗?
我在清单文件中有以下配置 -
<activity
android:name=".activities.PopupWord"
android:excludeFromRecents="true"
android:theme="@style/popups">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PROCESS_TEXT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
我可以在 Android 10 中的 Twitter 等应用程序的文本选择菜单中看到“查找”按钮,但在 Android 11 中它消失了。令人惊讶的是它在 Chrome 中运行。
维基百科测试版以某种方式规避了这个问题,并在各处显示其“在维基百科中搜索”按钮。我试图查看它的清单,发现它很相似。
<activity
android:name="org.wikipedia.search.SearchActivity"
android:windowSoftInputMode="0x10">
<intent-filter
android:label="@ref/0x7f100190">
<action
android:name="android.intent.action.SEND" />
<category
android:name="android.intent.category.DEFAULT" />
<data
android:mimeType="text/plain" />
</intent-filter>
<intent-filter
android:label="@ref/0x7f100190">
<action
android:name="android.intent.action.PROCESS_TEXT" />
<category
android:name="android.intent.category.DEFAULT" />
<data
android:mimeType="text/plain" />
</intent-filter>
</activity> …Run Code Online (Sandbox Code Playgroud) 我需要检查其他应用程序是否具有外部存储管理器的权限。和
Environment.isExternalStorageManager()
Run Code Online (Sandbox Code Playgroud)
我检查当前应用程序是否已被授予。我如何为另一个应用程序执行此操作?我已经尝试检查权限状态
getPackageManager().checkPermission(Manifest.permission.MANAGE_EXTERNAL_STORAGE, "dk.tacit.android.foldersync.lite")
Run Code Online (Sandbox Code Playgroud)
但它总是返回 -1,这意味着 PERMISSION_DENIED,即使授予了权限。
android-11 ×10
android ×9
android-wifi ×1
gradle ×1
java ×1
permissions ×1
root ×1
storage ×1
wifimanager ×1