Get IntentSender object for createChooser method in Android -
i use new version of intent.createchooser method uses intentsender
.
documentation states can grab pendingintent
instance. in case seems pendingintent
won't have other use.
is there way obtain intentsender
or need create pendingintent
?
the chooser target intent not pendingintent
. instance, in following snippet, declaring intent action_send
, type text/plain
, , target intent intent.createchooser
. creating intent
, receiver, , handler, pendingintet
, invoke onreceive
of broadcasttest
after 1 pick chooser.
intent intent = new intent(intent.action_send); intent.putextra(intent.extra_text, "this text send."); intent.settype("text/plain"); intent receiver = new intent(this, broadcasttest.class); receiver.putextra("test", "test"); pendingintent pendingintent = pendingintent.getbroadcast(this, 0, receiver, pendingintent.flag_update_current); intent chooser = intent.createchooser(intent, "test", pendingintent.getintentsender()); startactivity(chooser);
edit:
the information, in case of broadcastreceiver
embedded in intent parameter. after selected 1 of option, retrieve bundle's extras , using key android.intent.extra.chosen_component
, should able find user picked.
try adding simple log.d onreceive
for (string key : intent.getextras().keyset()) { log.d(getclass().getsimplename(), " " + intent.getextras().get(key)); }
in example got
componentinfo{org.telegram.messenger/org.telegram.ui.launchactivity}
for telegram
,
componentinfo{com.google.android.apps.inbox/com.google.android.apps.bigtop.activities.composemessageactivity}
for inbox
Comments
Post a Comment