@@ -71,12 +71,9 @@ public void onLeScan(final BluetoothDevice device, final int rssi, final byte[]
7171 }
7272 }
7373
74- runOnUiThread (new Runnable () {
75- @ Override
76- public void run () {
77- mRecyclerAdapter .setData (itemList );
78- updateItemCount (mRecyclerAdapter .getItemCount ());
79- }
74+ runOnUiThread (() -> {
75+ mRecyclerAdapter .setData (itemList );
76+ updateItemCount (mRecyclerAdapter .getItemCount ());
8077 });
8178 }
8279 };
@@ -166,8 +163,17 @@ private void startScanPrepare() {
166163 // The COARSE_LOCATION permission is only needed after API 23 to do a BTLE scan
167164 //
168165 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
166+ final String permission ;
167+ final int message ;
168+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q ) {
169+ permission = Manifest .permission .ACCESS_FINE_LOCATION ;
170+ message = R .string .permission_not_granted_fine_location ;
171+ } else {
172+ permission = Manifest .permission .ACCESS_COARSE_LOCATION ;
173+ message = R .string .permission_not_granted_coarse_location ;
174+ }
169175 PermissionsManager .getInstance ().requestPermissionsIfNecessaryForResult (this ,
170- new String []{Manifest . permission . ACCESS_COARSE_LOCATION }, new PermissionsResultAction () {
176+ new String []{permission }, new PermissionsResultAction () {
171177
172178 @ Override
173179 public void onGranted () {
@@ -177,7 +183,7 @@ public void onGranted() {
177183 @ Override
178184 public void onDenied (String permission ) {
179185 Toast .makeText (MainActivity .this ,
180- R . string . permission_not_granted_coarse_location ,
186+ message ,
181187 Toast .LENGTH_SHORT )
182188 .show ();
183189 }
0 commit comments