code:
Intent launchIntent = new Intent(Intent.ACTION_MAIN);
launchIntent.addCategory(Intent.CATEGORY_HOME);
Intent chooser = Intent.createChooser(launchIntent, "Complete Action using..");
activity.startActivity(chooser);
我看不出有什么方法来判断哪些意图(HOME类启动器)被选中。没有Inent.addOnActionSetListener,也没有chooser.addOnIntentChosenListener等,所以我怎么能知道哪些选择?难道还是我写我自己的选择器来呢?
I don't see any way to tell which Intent (HOME category launcher) was selected. There is no Inent.addOnActionSetListener, and no chooser.addOnIntentChosenListener etc. So how can I tell which was selected? Do Or do I have to write my own chooser for this?
在Android 5.1+,你可以使用的三参数版 createChooser()
方法,其中最后一个参数是 IntentSender
,你可以用它来找出被选中。
On Android 5.1+, you can use the three-parameter edition of the createChooser()
method, where the last parameter is an IntentSender
that you can use to find out what was chosen.
在此之前的Android 5.1,没有什么在Android中,让你知道什么样的用户选择。
Prior to Android 5.1, there is nothing in Android to let you know what the user chose.