我希望我的应用程序打开SIM卡工具包,以便用户可以通过SIM卡工具包应用程序中提供的移动的进行支付请帮助。Kotlin我试着使用intent,但我不知道怎么用。
mrwjdhj31#
fun launchSTK(activity: Context) { val intent = activity.packageManager.getLaunchIntentForPackage("com.android.stk") if (intent == null) { try { val intent1 = Intent() intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) intent1.addCategory("android.intent.category.LAUNCHER") intent1.action = "android.intent.action.MAIN" intent1.type = "text/plain" intent1.component = ComponentName("com.android.stk", "com.android.stk.StkLauncherActivity") activity.startActivity(intent1) return } catch (activitynotfoundexception: ActivityNotFoundException) { } } else if (intent == null) { try { val intent2 = Intent() intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) intent2.addCategory("android.intent.category.LAUNCHER") intent2.action = "android.intent.action.MAIN" intent2.type = "text/plain" intent2.component = ComponentName("com.android.stk", "com.android.stk.StkMain") activity.startActivity(intent2) return } catch (activitynotfoundexception1: ActivityNotFoundException) { } } else if (intent == null) { val intent3 = Intent() intent3.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) intent3.addCategory("android.intent.category.LAUNCHER") intent3.action = "android.intent.action.MAIN" intent3.type = "text/plain" intent3.component = ComponentName("com.android.stk", "com.android.stk.StkLauncherActivity") activity.startActivity(intent3) } else if (intent == null) { val intent4 = Intent() intent4.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) intent4.addCategory("android.intent.category.LAUNCHER") intent4.action = "android.intent.action.MAIN" intent4.type = "text/plain" intent4.component = ComponentName("com.android.stk", "com.android.stk.StkMain") activity.startActivity(intent4) } else if (intent == null) { val launchIntent5 = activity.packageManager.getLaunchIntentForPackage("com.mediatek.StkSelection") activity.startActivity(launchIntent5) } else { activity.startActivity(intent) } return }
1条答案
按热度按时间mrwjdhj31#