首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >蓝牙LE在android 6.0上找不到任何设备

蓝牙LE在android 6.0上找不到任何设备
EN

Stack Overflow用户
提问于 2018-12-14 05:07:26
回答 2查看 240关注 0票数 0

我正在构建一个应用程序,从蓝牙设备接收数据,并在4.4.4安卓智能手机上功能齐全。但是当我在6.0版本的设备上试用它时,它找不到蓝牙设备。我已经在手机上激活了位置,并且我已经在清单文件上添加了位置的权限,但什么也没有发生。

我在某处读到,我必须请求用户的权限,并且我尝试添加

ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, 1001); //Any number

在我的活动的清单上,但是我得到错误"cannot resolve symbol AcivityCompat“和"cannot resolve symbol Manifest...

我的build.gradle文件是:

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
    applicationId "com.redbear.chat"
    minSdkVersion 18
    targetSdkVersion 26
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {
implementation 'com.android.support:support-v4:28.+'
implementation 'com.google.android.gms:play-services-location:16.0.0'
}

我的清单文件是:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.redbear.chat"
android:versionCode="1"
android:versionName="1.0" >

<uses-feature
    android:name="android.hardware.bluetooth_le"
    android:required="true" />

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Needed only if your app targets Android 5.0 (API level 21) or higher. -->
<uses-feature android:name="android.hardware.location.gps" />
<uses-feature android:name="android.hardware.location.network" />



<application
    android:allowBackup="true"
    android:icon="@drawable/redbear"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.redbear.chat.Main"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.redbear.chat.Chat"
        android:windowSoftInputMode="stateHidden" >
    </activity>
    <activity
        android:name=".Device"
        android:theme="@android:style/Theme.Dialog" >
    </activity>

    <service
        android:name="com.redbear.chat.RBLService"
        android:enabled="true" />
</application>

</manifest>
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53770081

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档