Class DocumentSharingIntentHelper
-
- All Implemented Interfaces:
public class DocumentSharingIntentHelper
Helper for creating share intents.
-
-
Field Summary
Fields Modifier and Type Field Description public final static String
MIME_TYPE_PDF
-
Constructor Summary
Constructors Constructor Description DocumentSharingIntentHelper()
-
Method Summary
Modifier and Type Method Description static Intent
getShareTextIntent(@NonNull() String text)
Generates intent for sharing plain text. static List<Intent>
getShareIntents(@NonNull() Context context, @NonNull() Uri shareUri, @NonNull() Array<ShareAction> shareActions)
Generates list of sharing intents for all apps supporting given ShareAction. static Observable<List<Intent>>
getShareIntentsAsync(@NonNull() Context context, @NonNull() Uri shareUri, @NonNull() ShareAction shareAction)
Generates list of sharing intents for all apps supporting given ShareAction asynchronously. static List<ShareTarget>
getShareTargets(@NonNull() Context context, @NonNull() List<Intent> intents)
Generates list of share targets for all apps handling given intents. static Observable<List<ShareTarget>>
getShareTargetsAsync(@NonNull() Context context, @NonNull() List<Intent> intents)
Generates list of share targets for all apps handling given intents. static Intent
getShareIntent(@NonNull() Context context, @NonNull() Uri shareUri, @NonNull() ShareTarget shareTarget)
Creates share intent for sharing shareUri
to givenshareTarget
.static Intent
getShareIntent(@NonNull() Context context, @NonNull() Uri shareUri, @NonNull() ShareAction shareAction)
Creates share intent for sharing shareUri
using givenshareAction
.static Intent
getShareIntent(@NonNull() Context context, @NonNull() ShareAction shareAction, @Nullable() String sharedFileName)
Creates share intent for sharing PDF file from DocumentSharingProvider with shareAction
.static ShareTarget
getShareTarget(@NonNull() Context context, @NonNull() ShareAction shareAction, @NonNull() String targetPackageName)
Creates ShareTarget for given shareAction
andtargetPackageName
.static ShareTarget
getShareTarget(@NonNull() Context context, @NonNull() ShareAction shareAction, @NonNull() String targetPackageName, @Nullable() String sharedFileName)
Creates ShareTarget for given shareAction
andtargetPackageName
.static void
showShareTargetDetails(@NonNull() Context context, @NonNull() ShareTarget shareTarget)
Show application details settings screen for given share target. -
-
Method Detail
-
getShareTextIntent
@NonNull() static Intent getShareTextIntent(@NonNull() String text)
Generates intent for sharing plain text.
- Parameters:
text
- Text to be shared.
-
getShareIntents
@NonNull() static List<Intent> getShareIntents(@NonNull() Context context, @NonNull() Uri shareUri, @NonNull() Array<ShareAction> shareActions)
Generates list of sharing intents for all apps supporting given ShareAction.
Note: this call may block for a while and should not be invoked on the main thread.
- Parameters:
shareUri
- Uri that we want to share.shareActions
- Share actions that should be used.
-
getShareIntentsAsync
@NonNull() static Observable<List<Intent>> getShareIntentsAsync(@NonNull() Context context, @NonNull() Uri shareUri, @NonNull() ShareAction shareAction)
Generates list of sharing intents for all apps supporting given ShareAction asynchronously.
- Parameters:
context
- Context to use.shareUri
- Uri that we want to share.shareAction
- Share actions that should be used.- Returns:
Observable emitting list of sharing intents.
-
getShareTargets
@NonNull() static List<ShareTarget> getShareTargets(@NonNull() Context context, @NonNull() List<Intent> intents)
Generates list of share targets for all apps handling given intents.
Note: this call may block for a while and should not be invoked on the main thread.
- Parameters:
intents
- Intents used for sharing.
-
getShareTargetsAsync
@NonNull() static Observable<List<ShareTarget>> getShareTargetsAsync(@NonNull() Context context, @NonNull() List<Intent> intents)
Generates list of share targets for all apps handling given intents.
- Parameters:
intents
- Intents used for sharing.- Returns:
Observable emitting list of share targets.
-
getShareIntent
@Nullable() static Intent getShareIntent(@NonNull() Context context, @NonNull() Uri shareUri, @NonNull() ShareTarget shareTarget)
Creates share intent for sharing
shareUri
to givenshareTarget
.
-
getShareIntent
@NonNull() static Intent getShareIntent(@NonNull() Context context, @NonNull() Uri shareUri, @NonNull() ShareAction shareAction)
Creates share intent for sharing
shareUri
using givenshareAction
.
-
getShareIntent
@Nullable() static Intent getShareIntent(@NonNull() Context context, @NonNull() ShareAction shareAction, @Nullable() String sharedFileName)
Creates share intent for sharing PDF file from DocumentSharingProvider with
shareAction
. Use this method to retrieve intent that can be used to retrieve share targets via queryShareTargets.
-
getShareTarget
@Nullable() static ShareTarget getShareTarget(@NonNull() Context context, @NonNull() ShareAction shareAction, @NonNull() String targetPackageName)
Creates ShareTarget for given
shareAction
andtargetPackageName
.- Parameters:
context
- The context to use.shareAction
- Share action to create share target for.targetPackageName
- Package name of share target.- Returns:
ShareTarget with data resolved from package manager or null if could not be resolved.
-
getShareTarget
@Nullable() static ShareTarget getShareTarget(@NonNull() Context context, @NonNull() ShareAction shareAction, @NonNull() String targetPackageName, @Nullable() String sharedFileName)
Creates ShareTarget for given
shareAction
andtargetPackageName
.- Parameters:
context
- The context to use.shareAction
- Share action to create share target for.targetPackageName
- Package name of share target.sharedFileName
- File name of the file that should be shared.- Returns:
ShareTarget with data resolved from package manager or null if could not be resolved.
-
showShareTargetDetails
static void showShareTargetDetails(@NonNull() Context context, @NonNull() ShareTarget shareTarget)
Show application details settings screen for given share target.
- Parameters:
context
- The context to use.shareTarget
- Share target for which to display app details.
-
-
-
-