カスタム共有もパッケージ可視性の対応が必要
This commit is contained in:
parent
5b4f304f24
commit
0735441c42
@ -12,21 +12,32 @@
|
|||||||
<!-- CAMERAパーミッションをつけるとPlayストアにプライバシーポリシーを記載する必要がある -->
|
<!-- CAMERAパーミッションをつけるとPlayストアにプライバシーポリシーを記載する必要がある -->
|
||||||
<!--<uses-permission android:name="android.permission.CAMERA"/>-->
|
<!--<uses-permission android:name="android.permission.CAMERA"/>-->
|
||||||
|
|
||||||
|
<!--suppress AndroidElementNotAllowed -->
|
||||||
<queries>
|
<queries>
|
||||||
|
|
||||||
<intent>
|
<intent>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
<data android:scheme="https" />
|
<data android:scheme="https" />
|
||||||
</intent>
|
</intent>
|
||||||
|
|
||||||
<!-- <intent>-->
|
<intent>
|
||||||
<!-- <action android:name="android.intent.action.SEND" />-->
|
<action android:name="android.support.customtabs.action.CustomTabsService" />
|
||||||
<!-- <data android:mimeType="video/*" />-->
|
</intent>
|
||||||
<!-- </intent>-->
|
|
||||||
<!-- <intent>-->
|
<intent>
|
||||||
<!-- <action android:name="android.intent.action.VIEW" />-->
|
<action android:name="android.intent.action.SEND" />
|
||||||
<!-- <data android:mimeType="video/*" />-->
|
<data android:mimeType="text/plain" />
|
||||||
<!-- </intent>-->
|
</intent>
|
||||||
|
|
||||||
|
<!-- <intent>-->
|
||||||
|
<!-- <action android:name="android.intent.action.SEND" />-->
|
||||||
|
<!-- <data android:mimeType="video/*" />-->
|
||||||
|
<!-- </intent>-->
|
||||||
|
<!-- <intent>-->
|
||||||
|
<!-- <action android:name="android.intent.action.VIEW" />-->
|
||||||
|
<!-- <data android:mimeType="video/*" />-->
|
||||||
|
<!-- </intent>-->
|
||||||
</queries>
|
</queries>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
@ -1806,33 +1806,30 @@ class ActMain : AsyncActivity(), Column.Callback, View.OnClickListener,
|
|||||||
// queryIntentActivities に渡すURLは実在しないホストのものにする
|
// queryIntentActivities に渡すURLは実在しないホストのものにする
|
||||||
val intent = Intent(Intent.ACTION_VIEW, "https://dummy.subwaytooter.club/".toUri())
|
val intent = Intent(Intent.ACTION_VIEW, "https://dummy.subwaytooter.club/".toUri())
|
||||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
|
|
||||||
|
val my_name = packageName
|
||||||
val resolveInfoList = packageManager.queryIntentActivities(intent, query_flag)
|
val resolveInfoList = packageManager.queryIntentActivities(intent, query_flag)
|
||||||
|
.filter{ my_name != it.activityInfo.packageName}
|
||||||
|
|
||||||
if(resolveInfoList.isEmpty()) {
|
if(resolveInfoList.isEmpty()) {
|
||||||
throw RuntimeException("resolveInfoList is empty.")
|
throw RuntimeException("resolveInfoList is empty.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// このアプリ以外の選択肢を集める
|
// このアプリ以外の選択肢を集める
|
||||||
val my_name = packageName
|
val choice_list = resolveInfoList
|
||||||
val choice_list = ArrayList<Intent>()
|
.map{
|
||||||
for(ri in resolveInfoList) {
|
Intent(Intent.ACTION_VIEW, uri).apply{
|
||||||
|
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
// 選択肢からこのアプリを除外
|
`package` = it.activityInfo.packageName
|
||||||
if(my_name == ri.activityInfo.packageName) continue
|
setClassName(it.activityInfo.packageName, it.activityInfo.name)
|
||||||
|
}
|
||||||
// 選択肢のIntentは目的のUriで作成する
|
}.toMutableList()
|
||||||
val choice = Intent(Intent.ACTION_VIEW, uri)
|
|
||||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
|
||||||
choice.`package` = ri.activityInfo.packageName
|
|
||||||
choice.setClassName(ri.activityInfo.packageName, ri.activityInfo.name)
|
|
||||||
choice_list.add(choice)
|
|
||||||
}
|
|
||||||
|
|
||||||
if(choice_list.isEmpty()) {
|
|
||||||
throw RuntimeException("choice_list is empty.")
|
|
||||||
}
|
|
||||||
// 指定した選択肢でチューザーを作成して開く
|
|
||||||
val chooser = Intent.createChooser(choice_list.removeAt(0), error_message)
|
val chooser = Intent.createChooser(choice_list.removeAt(0), error_message)
|
||||||
|
// 2つめ以降はEXTRAに渡す
|
||||||
chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, choice_list.toTypedArray())
|
chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, choice_list.toTypedArray())
|
||||||
|
|
||||||
|
// 指定した選択肢でチューザーを作成して開く
|
||||||
startActivity(chooser)
|
startActivity(chooser)
|
||||||
return
|
return
|
||||||
} catch(ex : Throwable) {
|
} catch(ex : Throwable) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user