2

I am trying to find a way to impelement a share button into my app (same like the one in the standard ICS gallary app, see picture link). http://betanews.com/2011/10/19/get-acquainted-with-the-newest-android-ice-cream-sandwich-slideshow/#11

Intent.ACTION_SEND only opens a dialoge to the select the sharing options. Android Share Via Dialog

This works fine, but from design side, I find this drop down list to select a app much more convenient. Yet I cant figure out how to? Does anybody have a good Idea how this button could be coded?

Community
  • 1
  • 1
KarlKarlsom
  • 5,868
  • 4
  • 29
  • 36

2 Answers2

3

That is implemented using a ListPopupWindow, which at the moment is only available on Android 4.0.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Ok, I checked the ListPopupWindow. This is capable to view a ListAdapter. But how to fill this Listadapter with all installed app, that can receive a certain kind of file / data? – KarlKarlsom Jan 01 '12 at 22:54
  • @KarlKarlsom: Please ask separate StackOverflow questions for things that do not relate to a previous question. Comments are not a place to ask unrelated questions. That being said, you would use `PackageManager` and `queryIntentActivities()` to populate your list. The actual display-a-share-list-via-a-`ListPopupWindow` is implemented as [`ShareActionProvider`](http://developer.android.com/reference/android/widget/ShareActionProvider.html), and since the Android 4.0 source code is available, you could always examine that to see exactly how they do it. – CommonsWare Jan 01 '12 at 23:02
2

This is implemented using ShareActionProvider available in SDK14+.

ActionProvider class replaces an action item with a customized layout, but it also takes control of all the item's behaviors. When you declare an action provider for a menu item in the action bar, it not only controls the appearance of the item in the action bar with a custom layout, but also handles the default event for the menu item when it appears in the overflow menu

Its quiet easy to implement, you can follow the official documentation here.

Taranfx
  • 10,361
  • 17
  • 77
  • 95