Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
820 views
in Technique[技术] by (71.8m points)

bluetooth lowenergy - Android Companion device pairing: how to use REQUEST_COMPANION_RUN_IN_BACKGROUND permission?

I'm currently testing Android companion device pairing and I'm not sure how to benefit from the REQUEST_COMPANION_RUN_IN_BACKGROUND permission.

In one part of Google documentation is says:

After the device is paired, the device can leverage the REQUEST_COMPANION_RUN_IN_BACKGROUND and REQUEST_COMPANION_USE_DATA_IN_BACKGROUND permissions to start the app from the background. You might use this method of pairing devices for initial configuration of a BLE-capable smart watch, for example.

in the permission itself:

Allows a companion app to run in the background.

and in the CompanionDeviceManager documentation it says:

If your app needs to be excluded from battery optimizations (run in the background) or to have unrestricted data access (use data in the background) you can declare that you use the android.Manifest.permission#REQUEST_COMPANION_RUN_IN_BACKGROUND and respectively.

Can someone please explain (or point me towards some sample code) how to leverage this permission in order to run the app in the background? Ideally I would like trigger an action in the companion app from the paired Bluetooth LE peripheral device.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...