1 <?xml version="1.0" encoding="UTF-8"?> 2 <!-- 3 Copyright 2015 The Android Open Source Project 4 5 Licensed under the Apache License, Version 2.0 (the "License"); 6 you may not use this file except in compliance with the License. 7 You may obtain a copy of the License at 8 9 http://www.apache.org/licenses/LICENSE-2.0 10 11 Unless required by applicable law or agreed to in writing, software 12 distributed under the License is distributed on an "AS IS" BASIS, 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 See the License for the specific language governing permissions and 15 limitations under the License. 16 --> 17 <sample> 18 <name>DirectShare</name> 19 <group>Content</group> 20 <package>com.example.android.directshare</package> 21 22 <minSdk>23</minSdk> 23 24 <strings> 25 <intro> 26 <![CDATA[ 27 This sample demonstrates how to provide the Direct Share feature. The app shows some options 28 directly in the list of share intent candidates. 29 ]]> 30 </intro> 31 </strings> 32 33 <template src="base"/> 34 35 <metadata> 36 <status>PUBLISHED</status> 37 <categories>Content</categories> 38 <technologies>Android</technologies> 39 <languages>Java</languages> 40 <solutions>Mobile</solutions> 41 <level>INTERMEDIATE</level> 42 <icon>screenshots/icon-web.png</icon> 43 <screenshots> 44 <img>screenshots/1-main.png</img> 45 <img>screenshots/2-intent.png</img> 46 <img>screenshots/3-message.png</img> 47 </screenshots> 48 <api_refs> 49 <android>android.service.chooser.ChooserTargetService</android> 50 <android>android.service.chooser.ChooserTarget</android> 51 </api_refs> 52 <description> 53 <![CDATA[ 54 Sample demonstrating how to show some options directly in the list of share intent candidates. 55 ]]> 56 </description> 57 <intro> 58 <![CDATA[ 59 [Direct Share][1] is a feature that allows apps to show their internal options directly in the 60 system Intent chooser dialog. This sample is a dummy messaging app, and just like any other 61 messaging apps, it receives intents for sharing a plain text. When a user shares some text from some 62 other app, this sample app will be listed as an option. Using the Direct Share feature, this app 63 also shows some of contacts directly in the chooser dialog. 64 65 To enable Direct Share, apps need to implement a Service extending 66 [ChooserTargetService][2]. Override the method [onGetChooserTargets][3] and return a list of Direct 67 Share options. 68 69 In your AndroidManifest.xml, add a meta-data tag in your Activity that receives the Intent. Specify 70 android:name as android.service.chooser.chooser_target_service, and point the android:value to the 71 Service. 72 73 [1]: https://developer.android.com/reference/android/service/chooser/package-summary.html 74 [2]: https://developer.android.com/reference/android/service/chooser/ChooserTargetService.html 75 [3]: https://developer.android.com/reference/android/service/chooser/ChooserTargetService.html#onGetChooserTargets(android.content.ComponentName%2C%20android.content.IntentFilter) 76 ]]> 77 </intro> 78 </metadata> 79 </sample> 80