小编Pra*_*pat的帖子

可能的透支:根元素绘制背景,主题也绘制背景

我已经实现了可点击的Recyclerview项目并设置android:background="?selectableItemBackground"了点击效果,但在检查代码时我发现了这个lint问题.

Lint警告:可能的透支:根元素绘制背景?selectableItemBackground,主题也绘制背景

有什么想法解决这个警告?

我的xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?selectableItemBackground"
    android:clickable="true"
    android:orientation="vertical"
    android:padding="@dimen/row_padding">

    //...
</LinearLayout >
Run Code Online (Sandbox Code Playgroud)

xml android lint android-layout android-view

13
推荐指数
1
解决办法
1886
查看次数

如何在我的Android应用程序中启动Android应用程序?

在我的应用程序中有标签布局.和两个标签.

  • 选项卡1 - 我的应用程序 在此输入图像描述
  • 选项卡2 - 任何外部Android应用程序(如联系人,呼叫拨号器等..)(我知道如何启动外部应用程序,但它不在我的应用程序中运行(意味着选项卡将不会在启动后显示)).

提前致谢

android android-activity

11
推荐指数
2
解决办法
2134
查看次数

Android 13 - 需要蓝牙特权权限吗?

仅在 Android 13 设备的生产应用程序中观察到一些崩溃。

所有蓝牙相关权限均在清单中声明,并且附近的设备运行时权限也已到位。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    android:installLocation="auto">

    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission
        android:name="android.permission.BLUETOOTH_ADMIN"
        android:maxSdkVersion="33" />
    <uses-permission
        android:name="android.permission.BLUETOOTH_SCAN"
        android:usesPermissionFlags="neverForLocation"
        tools:ignore="UnusedAttribute" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
  
    <uses-permission
        android:name="android.permission.ACCESS_COARSE_LOCATION"
        android:maxSdkVersion="31" />
    <uses-permission
        android:name="android.permission.ACCESS_FINE_LOCATION"
        android:maxSdkVersion="31" />
</manifest>
Run Code Online (Sandbox Code Playgroud)

崩溃日志:

Fatal Exception: java.lang.SecurityException: Need BLUETOOTH PRIVILEGED permission: Neither user 10370 nor current process has android.permission.BLUETOOTH_PRIVILEGED.
       at android.app.ContextImpl.enforce(ContextImpl.java:2240)
       at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:2268)
       at android.content.ContextWrapper.enforceCallingOrSelfPermission(ContextWrapper.java:948)
       at com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission(Utils.java:411)
       at com.android.bluetooth.gatt.GattService.permissionCheck(GattService.java:474)
       at com.android.bluetooth.gatt.GattService.registerForNotification(GattService.java:3801)
       at com.android.bluetooth.gatt.GattService$BluetoothGattBinder.registerForNotification(GattService.java:1085)
       at com.android.bluetooth.gatt.GattService$BluetoothGattBinder.registerForNotification(GattService.java:1073)
       at android.bluetooth.IBluetoothGatt$Stub.onTransact(IBluetoothGatt.java:812)
       at android.os.Binder.execTransactInternal(Binder.java:1285)
       at android.os.Binder.execTransact(Binder.java:1244)
Run Code Online (Sandbox Code Playgroud)

android bluetooth bluetooth-lowenergy android-13

7
推荐指数
1
解决办法
6096
查看次数

在表达式中删除 Kotlin 中的中断

如何在不破坏表达式的情况下在 kotlin 中编写When Expression?在 Java 中,我们可以这样做。

int x = 3;
switch (x){
   case 1:
      System.out.println("1");
   case 2:
      System.out.println("2");  
   case 3:
      System.out.println("3");  // 3 will be printed
   case 4:
      System.out.println("4");  // 4 will be printed
}
Run Code Online (Sandbox Code Playgroud)

结果:
3
4

我怎样才能达到这样的结果?

java switch-statement kotlin

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