Skip to content

Commit

Permalink
manifest permissions update
Browse files Browse the repository at this point in the history
  • Loading branch information
mglsj committed Apr 30, 2024
1 parent e22d4de commit c8dff59
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 18 deletions.
23 changes: 17 additions & 6 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pkmnapps.nearby_connections">

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- Required for Nearby Connections -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:minSdkVersion="29"
android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:minSdkVersion="31"
android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:minSdkVersion="31"
android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:minSdkVersion="31"
android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:minSdkVersion="32"
android:name="android.permission.NEARBY_WIFI_DEVICES" />

<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
</manifest>
</manifest>
38 changes: 30 additions & 8 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<!-- Required for Nearby Connections -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:minSdkVersion="29"
android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:minSdkVersion="31"
android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:minSdkVersion="31"
android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:minSdkVersion="31"
android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:minSdkVersion="32"
android:name="android.permission.NEARBY_WIFI_DEVICES" />
<!-- Optional: only required for FILE payloads -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


<application
android:label="nearby_connections_example"
android:name="${applicationName}"
Expand All @@ -16,12 +38,12 @@
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"
/>
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
Expand All @@ -37,8 +59,8 @@
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
<action android:name="android.intent.action.PROCESS_TEXT" />
<data android:mimeType="text/plain" />
</intent>
</queries>
</manifest>
</manifest>
10 changes: 6 additions & 4 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class _MyBodyState extends State<Body> {
ElevatedButton(
child: const Text("checkLocationPermission (<= Android 12)"),
onPressed: () async {
if (await Permission.location.isGranted) {
if (await Permission.locationWhenInUse.isGranted) {
showSnackbar("Location permissions granted :)");
} else {
showSnackbar("Location permissions not granted :(");
Expand All @@ -71,7 +71,9 @@ class _MyBodyState extends State<Body> {
ElevatedButton(
child: const Text("askLocationPermission"),
onPressed: () async {
if (await Permission.location.request().isGranted) {
if (await Permission.locationWhenInUse
.request()
.isGranted) {
showSnackbar("Location permissions granted :)");
} else {
showSnackbar("Location permissions not granted :(");
Expand Down Expand Up @@ -113,8 +115,8 @@ class _MyBodyState extends State<Body> {
),
ElevatedButton(
child: const Text("askBluetoothPermission (Android 12+)"),
onPressed: () {
[
onPressed: () async {
await [
Permission.bluetooth,
Permission.bluetoothAdvertise,
Permission.bluetoothConnect,
Expand Down

0 comments on commit c8dff59

Please sign in to comment.