@@ -26,7 +26,7 @@ repositories {
2626
2727``` gradle
2828dependencies {
29- implementation 'org.deviceconnect:dconnect-demo-lib:0.9 .0'
29+ implementation 'org.deviceconnect:dconnect-demo-lib:1.0 .0'
3030 ...
3131}
3232```
@@ -189,6 +189,30 @@ public class HostDemoInstaller extends DemoInstaller {
189189 }
190190```
191191
192+ ## ContentProvider の定義
193+ Android 10 以降、ファイルの保存場所はプライベートな領域に限られます。デモアプリを外部に公開するためには、ContentProvider が必要になります。
194+
195+ 以下のように、AndroidManifest.xml に ` <provider> ` の定義を追加してください。
196+
197+ ``` xml
198+ <provider
199+ android : name =" org.deviceconnect.android.provider.FileProvider"
200+ android : authorities =" <プラグインのパッケージ名>.provider"
201+ android : exported =" true" >
202+ <meta-data
203+ android : name =" filelocation"
204+ android : resource =" @xml/filelocation" />
205+ </provider >
206+ ```
207+
208+ また、プラグインの ` res/xml ` フォルダに、以下の内容の ` filelocation.xml ` を追加してください。
209+
210+ ``` xml
211+ <?xml version =" 1.0" encoding =" UTF-8" ?>
212+ <file-locations >
213+ <external-location path =" " />
214+ </file-locations >
215+ ```
192216
193217## インストール用画面の組み込み
194218デモアプリを端末にインストール・アンインストールするためのUIは、以下の ` Fragment ` クラスで提供されます。
@@ -223,9 +247,18 @@ org.deviceconnect.android.deviceplugin.demo.DemoSettingFragment
223247デモアプリをインテント経由で表示するための URI を返します。
224248
225249``` java
250+ private static final String FILE_PROVIDER_AUTHORITY = " <Manifestで定義したFilePrpviderのauthorities名>" ;
251+
226252 @Override
227253 protected String getShortcutUri(final DemoInstaller installer) {
228- return " gotapi://shortcut/" + installer. getPluginPackageName() + " /demo/<トップページのhtmlファイルへの相対パス>" ;
254+ String rootPath;
255+ String filePath = " /demo/<トップページのhtmlファイルへの相対パス>" ;
256+ if (Build . VERSION. SDK_INT >= Build . VERSION_CODES. Q ) {
257+ rootPath = " /" + FILE_PROVIDER_AUTHORITY ;
258+ } else {
259+ rootPath = " /" + installer. getPluginPackageName();
260+ }
261+ return " gotapi://shortcut" + rootPath + filePath;
229262 }
230263```
231264
0 commit comments