Extra helper functionality for sharing data between activities. ShareCompat provides functionality to extend theACTION_SEND
/ ACTION_SEND_MULTIPLE
protocol and support retrieving more info about the activity that invoked a social sha ring action. ShareCompat.IntentBuilder
provides helper functions for constructing a sharing intent that always includes data about the calling activity and app. This lets the called activity provide attribution for the app that shared content. Constructing an intent this way can be done in a method-chaining style. To obtain an IntentBuilder with info about your calling activity, use the static method from(Activity)
. ShareCompat.IntentReader
provides helper functions for parsing the defined extras within an ACTION_SEND
or ACTION_SEND_MULTIPLE
intent used to launch an activity. You can also obtain a Drawable for the caller's application icon and the application's localized label (the app's human-readable name). Social apps that enable sharing content are encouraged to use this information to call out the app that the content was shared from.
这个是在activities共享数据的辅助功能类。ShareCompat提供了扩展ACTION_SEND/ACTION_SEND_MULITPLE端口和支持获取更多的数据关于activity来触发一个social sha ring。ShareCompat.IntentBuilder提供了帮助功能来构造一个共享的intent,它包含了关于调用activity和app的所有数据。这让调用的activity提供了共享内容的app的属性。
ShareCompat.IntentBuilder b=ShareCompat.IentBuilder.from(this);
b.setType("text/plain").setText("Share from Menu");
MenuItem item=menu.add("share");
ShareCompt.configureMenuItem(item,b);
MenuItemCompt.setShowAsAction(item,MenuITemCompt.Show_AS_ACTION_IF_ROOM);