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,
|
ActivityCompat.requestPermissions(activity,
|
||||||
new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION},
|
new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION},
|
||||||
0);
|
0);
|
||||||
|
Log.d("nearby_connections", "askLocationPermission");
|
||||||
result.success(null);
|
result.success(null);
|
||||||
break;
|
break;
|
||||||
case "checkExternalStoragePermission":
|
case "checkExternalStoragePermission":
|
||||||
@ -89,7 +90,15 @@ public class NearbyConnectionsPlugin implements MethodCallHandler {
|
|||||||
case "askExternalStoragePermission":
|
case "askExternalStoragePermission":
|
||||||
ActivityCompat.requestPermissions(activity,
|
ActivityCompat.requestPermissions(activity,
|
||||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
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);
|
result.success(null);
|
||||||
break;
|
break;
|
||||||
case "stopAdvertising":
|
case "stopAdvertising":
|
||||||
|
@ -3,4 +3,4 @@ library nearby_connections;
|
|||||||
|
|
||||||
export 'src/classes.dart';
|
export 'src/classes.dart';
|
||||||
export 'src/defs.dart';
|
export 'src/defs.dart';
|
||||||
export 'src/nearby_connections.dart';
|
export 'src/nearby.dart';
|
||||||
|
@ -176,6 +176,14 @@ class Nearby {
|
|||||||
'askExternalStoragePermission',
|
'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.
|
/// Start Advertising, Discoverers would be able to discover this advertiser.
|
||||||
///
|
///
|
||||||
/// [userNickName] and [strategy] should not be null
|
/// [userNickName] and [strategy] should not be null
|
||||||
@ -342,13 +350,13 @@ class Nearby {
|
|||||||
/// ```dart
|
/// ```dart
|
||||||
/// String a = "hello";
|
/// String a = "hello";
|
||||||
/// Uint8List bytes = Uint8List.fromList(a.codeUnits);
|
/// Uint8List bytes = Uint8List.fromList(a.codeUnits);
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// Convert bytes [Uint8List] to String as follows -
|
/// Convert bytes [Uint8List] to String as follows -
|
||||||
/// ```dart
|
/// ```dart
|
||||||
/// String str = String.fromCharCodes(payload.bytes);
|
/// String str = String.fromCharCodes(payload.bytes);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
Future<void> sendBytesPayload(String endpointId, Uint8List bytes) async {
|
Future<void> sendBytesPayload(String endpointId, Uint8List bytes) async {
|
||||||
assert(endpointId != null);
|
assert(endpointId != null);
|
||||||
|
|
||||||
@ -383,7 +391,7 @@ class Nearby {
|
|||||||
/// Use it to cancel/stop a payload transfer
|
/// Use it to cancel/stop a payload transfer
|
||||||
Future<void> cancelPayload(int payloadId) async {
|
Future<void> cancelPayload(int payloadId) async {
|
||||||
assert(payloadId != null);
|
assert(payloadId != null);
|
||||||
|
|
||||||
return await _channel.invokeMethod(
|
return await _channel.invokeMethod(
|
||||||
'cancelPayload',
|
'cancelPayload',
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
Loading…
Reference in New Issue
Block a user