获取ANDROID系统分享列表

fun getShareApps(context: Context): List? {
val packageManager: PackageManager = context.getPackageManager()
val appInfoVos: MutableList = ArrayList()
var resolveInfos: List = ArrayList()
val intent = Intent(Intent.ACTION_SEND, null)
intent.addCategory(Intent.CATEGORY_DEFAULT)
intent.type = "/"
val pManager: PackageManager = context.getPackageManager()
resolveInfos =
pManager.queryIntentActivities(intent, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT)
for (i in resolveInfos.indices) {
val appInfoVo = AppInfoVo()
val resolveInfo = resolveInfos[i]
appInfoVo.appName = resolveInfo.loadLabel(packageManager).toString()
appInfoVo.icon = resolveInfo.loadIcon(packageManager)
appInfoVo.packageName = resolveInfo.activityInfo.packageName
appInfoVo.launcherName = resolveInfo.activityInfo.name
appInfoVos.add(appInfoVo)
}
return appInfoVos
}

class AppInfoVo {
var icon: Drawable? = null
var appName: String? = null
var packageName: String? = null
var isSystemApp = false
var codesize: Long = 0
var launcherName: String? = null
}

其中,packageName、launcherName为分享页面

你可能感兴趣的:(获取ANDROID系统分享列表)