mirror of
https://github.com/hackku21/nearby_connections.git
synced 2024-10-27 19:14:01 +00:00
added new method, askLocationAndExternalStoragePermission
This commit is contained in:
parent
db7eeabef6
commit
59ca0c8292
@ -75,6 +75,7 @@ public class NearbyConnectionsPlugin implements MethodCallHandler {
|
||||
ActivityCompat.requestPermissions(activity,
|
||||
new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION},
|
||||
0);
|
||||
Log.d("nearby_connections", "askLocationPermission");
|
||||
result.success(null);
|
||||
break;
|
||||
case "checkExternalStoragePermission":
|
||||
@ -89,7 +90,15 @@ public class NearbyConnectionsPlugin implements MethodCallHandler {
|
||||
case "askExternalStoragePermission":
|
||||
ActivityCompat.requestPermissions(activity,
|
||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
||||
0);
|
||||
1);
|
||||
Log.d("nearby_connections", "askExternalStoragePermission");
|
||||
result.success(null);
|
||||
break;
|
||||
case "askLocationAndExternalStoragePermission":
|
||||
ActivityCompat.requestPermissions(activity,
|
||||
new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION,Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
||||
1);
|
||||
Log.d("nearby_connections", "askExternalStoragePermission");
|
||||
result.success(null);
|
||||
break;
|
||||
case "stopAdvertising":
|
||||
|
@ -3,4 +3,4 @@ library nearby_connections;
|
||||
|
||||
export 'src/classes.dart';
|
||||
export 'src/defs.dart';
|
||||
export 'src/nearby_connections.dart';
|
||||
export 'src/nearby.dart';
|
||||
|
@ -176,6 +176,14 @@ class Nearby {
|
||||
'askExternalStoragePermission',
|
||||
);
|
||||
|
||||
/// Convinience method
|
||||
///
|
||||
/// Use this instead of calling both [askLocationPermission()] and [askExternalStoragePermission()]
|
||||
Future<void> askLocationAndExternalStoragePermission() async =>
|
||||
await _channel.invokeMethod(
|
||||
'askLocationAndExternalStoragePermission',
|
||||
);
|
||||
|
||||
/// Start Advertising, Discoverers would be able to discover this advertiser.
|
||||
///
|
||||
/// [userNickName] and [strategy] should not be null
|
||||
@ -342,13 +350,13 @@ class Nearby {
|
||||
/// ```dart
|
||||
/// String a = "hello";
|
||||
/// Uint8List bytes = Uint8List.fromList(a.codeUnits);
|
||||
///
|
||||
///
|
||||
/// ```
|
||||
/// Convert bytes [Uint8List] to String as follows -
|
||||
/// ```dart
|
||||
/// String str = String.fromCharCodes(payload.bytes);
|
||||
/// ```
|
||||
///
|
||||
///
|
||||
Future<void> sendBytesPayload(String endpointId, Uint8List bytes) async {
|
||||
assert(endpointId != null);
|
||||
|
||||
@ -383,7 +391,7 @@ class Nearby {
|
||||
/// Use it to cancel/stop a payload transfer
|
||||
Future<void> cancelPayload(int payloadId) async {
|
||||
assert(payloadId != null);
|
||||
|
||||
|
||||
return await _channel.invokeMethod(
|
||||
'cancelPayload',
|
||||
<String, dynamic>{
|
Loading…
Reference in New Issue
Block a user