Skip to content

Commit 08048ce

Browse files
Merge pull request #485 from TakayukiHoshi1984/modify_linking_search_beacon
Linkingのビーコン検索サービスの開始処理の修正
2 parents da81528 + 4f8b21e commit 08048ce

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

  • dConnectDevicePlugin/dConnectDeviceLinking/app/src/main/java/org/deviceconnect/android/deviceplugin/linking/beacon

dConnectDevicePlugin/dConnectDeviceLinking/app/src/main/java/org/deviceconnect/android/deviceplugin/linking/beacon/LinkingBeaconManager.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import android.content.Context;
1010
import android.content.Intent;
11+
import android.os.Build;
1112
import android.util.Log;
1213

1314
import org.deviceconnect.android.deviceplugin.linking.lib.BuildConfig;
@@ -315,7 +316,11 @@ private void startBeaconScanInternal(final LinkingBeaconUtil.ScanMode scanMode)
315316
if (scanMode != null) {
316317
intent.putExtra(mContext.getPackageName() + LinkingBeaconUtil.EXTRA_SCAN_MODE, scanMode.getValue());
317318
}
318-
mContext.startService(intent);
319+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
320+
mContext.startForegroundService(intent);
321+
} else {
322+
mContext.startService(intent);
323+
}
319324
}
320325

321326
private void stopBeaconScanInternal() {
@@ -326,7 +331,11 @@ private void stopBeaconScanInternal() {
326331
Intent intent = new Intent();
327332
intent.setClassName(LinkingBeaconUtil.LINKING_PACKAGE_NAME, LinkingBeaconUtil.BEACON_SERVICE_NAME);
328333
intent.setAction(mContext.getPackageName() + LinkingBeaconUtil.ACTION_STOP_BEACON_SCAN);
329-
mContext.startService(intent);
334+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
335+
mContext.startForegroundService(intent);
336+
} else {
337+
mContext.startService(intent);
338+
}
330339
}
331340

332341
private void parseBeaconScanState(final Intent intent) {

0 commit comments

Comments
 (0)