android 无法给予麦克风访问通过flutter中的web视图加载的网站,它在ios中工作

1cklez4t  于 2022-12-16  发布在  Android
关注(0)|答案(1)|浏览(193)

你好,我正在flutter上开发一个应用程序,在这个应用程序中,我正在加载一个带有频率调谐器的外部网站,我不能在android设备上给予麦克风权限,但是在ios设备上可以正常工作。
使用的 Package package used for web view

webview_flutter: ^3.0.4

清单文件

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.krack_app">
   <application
        android:label="Krack"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher"
        android:usesCleartextTraffic="true">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize"
            android:showWhenLocked="true"
            android:turnScreenOn="true"
            
            >
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <!-- pusher local notification -->
            <meta-data
                android:name="com.google.firebase.messaging.default_notification_channel_id"
                android:value="krack_app_notification"
            />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <!-- pusher local notification -->
            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>
        <receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
          <intent-filter>
              <action android:name="android.intent.action.BOOT_COMPLETED"/>
              <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
              <action android:name="android.intent.action.QUICKBOOT_POWERON" />
              <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
          </intent-filter>
        </receiver>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
        <service
            android:name="com.dexterous.flutterlocalnotifications.ForegroundService"        
            android:exported="false"
            android:stopWithTask="false"/>
    </application>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"/>
    <uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <!--  -->
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.AUDIO_CAPTURE" />

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

用于权限的包

permission_handler: ^10.2.0

如果需要其他详细信息,请通知我
我试过从设备手动添加权限。Android中的Web视图仍然无法获得权限

6l7fqoea

6l7fqoea1#

我也有同样的问题。我在添加AndroidManifest.xml必要代码后向应用程序授予了麦克风权限,但webView不包括它。

if (await Permission.microphone.request().isGranted) {
  // Either the permission was already granted before or the user just granted it.
} else {
 // You can request multiple permissions at once.
Map<Permission, PermissionStatus> statuses = await 
  [Permission.microphone].request();
}
print(statuses[Permission.location]);

相关问题