Skip to content

Commit

Permalink
feat(android): implement openAppSettings for android (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
pwespi authored Nov 14, 2021
1 parent b40e690 commit 29abb16
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ _Note_: web support depends on the browser, see [implementation status](https://
| [`isLocationEnabled()`](#islocationenabled) ||||
| [`openLocationSettings()`](#openlocationsettings) ||||
| [`openBluetoothSettings()`](#openbluetoothsettings) ||||
| [`openAppSettings()`](#openappsettings) | |||
| [`openAppSettings()`](#openappsettings) | |||
| [`setDisplayStrings(...)`](#setdisplaystrings) ||| -- |
| [`requestDevice(...)`](#requestdevice) ||||
| [`requestLEScan(...)`](#requestlescan) ||| 🚩 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import android.content.Intent
import android.content.IntentFilter
import android.content.pm.PackageManager
import android.location.LocationManager
import android.net.Uri
import android.os.ParcelUuid
import android.provider.Settings.ACTION_BLUETOOTH_SETTINGS
import android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS
import android.provider.Settings.*
import android.util.Log
import androidx.core.location.LocationManagerCompat
import com.getcapacitor.*
Expand Down Expand Up @@ -178,20 +178,23 @@ class BluetoothLe : Plugin() {
@PluginMethod
fun openLocationSettings(call: PluginCall) {
val intent = Intent(ACTION_LOCATION_SOURCE_SETTINGS)
getActivity().startActivity(intent);
activity.startActivity(intent);
call.resolve()
}

@PluginMethod
fun openBluetoothSettings(call: PluginCall) {
val intent = Intent(ACTION_BLUETOOTH_SETTINGS)
getActivity().startActivity(intent);
activity.startActivity(intent);
call.resolve()
}

@PluginMethod
fun openAppSettings(call: PluginCall) {
call.unavailable("openAppSettings is not available on Android.")
val intent = Intent(ACTION_APPLICATION_DETAILS_SETTINGS)
intent.data = Uri.parse("package:" + getActivity().getPackageName());
activity.startActivity(intent);
call.resolve()
}

@PluginMethod
Expand Down
4 changes: 2 additions & 2 deletions src/bleClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ export interface BleClientInterface {

/**
* Open App settings.
* Only available on **iOS**.
* Not available on **web**.
* On **iOS** when a user declines the request to use Bluetooth on the first call of `initialize`, it is not possible
* to request for Bluetooth again from within the app. In this case Bluetooth has to be enabled in the app settings
* for the app to use it.
* for the app to be able use it.
*/
openAppSettings(): Promise<void>;

Expand Down

0 comments on commit 29abb16

Please sign in to comment.