Not able to give Microphone access to the website loaded via web view in flutter. Its working in ios

394 views Asked by At

Hi I'm working on an app in flutter. In the app I am loading an external website with a frequency tuner app. I'm not able to give microphone permission in android devices but its working fine in ios devices.

Package used package used for web view

webview_flutter: ^3.0.4

Manifest File

<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>

Package used for Permissions

permission_handler: ^10.2.0

Let me know any other details are required

I have tried adding permissions manually from the device. Still web view in android is not getting the permission

1

There are 1 answers

1
Faruk Ay On

I have same problem. I've granted microphone permission to the application after adding AndroidManifest.xml necessery code but webView doesn't include it.


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]);