我正在使用包管理器向我想要发送的内容发送意向。因此,我举了一些例子。但是当我运行此程序时,许多程序包被排除在外。我必须知道所有软件包,但事实并非如此。如何获得所有包裹?
var intent = Intent()
intent = Intent(Intent.ACTION_SEND)
intent.type = "application/*"
val resInfo = packageManager.queryIntentActivities(intent, 0)
val targetedShareIntents: MutableList<Intent> = ArrayList()
for (resolveInfo in resInfo) {
val packageName = resolveInfo.activityInfo.packageName
val targetedShareIntent = Intent(Intent.ACTION_SEND)
targetedShareIntent.type = "text/plain"
Log.d("TAG","name :"+packageName)
if (packageName.contains("google") || packageName.contains("kakao")) {
val name = ComponentName(packageName, resolveInfo.activityInfo.name)
targetedShareIntent.putExtra(Intent.EXTRA_TEXT, "TEXT")
targetedShareIntent.component = name
targetedShareIntent.setPackage(packageName)
targetedShareIntents.add(targetedShareIntent)
}
}
textShare.setOnClickListener {
val shareIntent = Intent.createChooser(targetedShareIntents.removeAt(0), "Title")
shareIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toTypedArray<Parcelable>())
startActivity(shareIntent)
}
日志
2020-03-30 21:19:20.173 25556-25556/? D/TAG: name :com.android.bluetooth
2020-03-30 21:19:20.183 25556-25556/? D/TAG: name :com.google.android.apps.maps
2020-03-30 21:19:20.183 25556-25556/? D/TAG: name :com.samsung.android.allshare.service.fileshare
2020-03-30 21:19:20.183 25556-25556/? D/TAG: name :com.samsung.android.app.simplesharing
2020-03-30 21:19:20.183 25556-25556/? D/TAG: name :com.samsung.android.messaging
2020-03-30 21:19:20.183 25556-25556/? D/TAG: name :com.samsung.android.scloud
2020-03-30 21:19:20.183 25556-25556/? D/TAG: name :com.adobe.reader
2020-03-30 21:19:20.183 25556-25556/? D/TAG: name :com.google.android.apps.docs
2020-03-30 21:19:20.183 25556-25556/? D/TAG: name :com.google.android.apps.photos
2020-03-30 21:19:20.183 25556-25556/? D/TAG: name :com.kakao.talk
2020-03-30 21:19:20.183 25556-25556/? D/TAG: name :com.microsoft.skydrive
2020-03-30 21:19:20.183 25556-25556/? D/TAG: name :com.samsung.android.app.notes
2020-03-30 21:19:20.183 25556-25556/? D/TAG: name :com.samsung.android.email.provider
2020-03-30 21:19:20.183 25556-25556/? D/TAG: name :com.samsung.android.oneconnect
2020-03-30 21:19:20.184 25556-25556/? D/TAG: name :com.samsung.android.voc
2020-03-30 21:19:20.184 25556-25556/? D/TAG: name :com.skt.tbagplus
2020-03-30 21:19:20.184 25556-25556/? D/TAG: name :jp.naver.line.android
2020-03-30 21:19:20.184 25556-25556/? D/TAG: name :jp.naver.line.android