-
Notifications
You must be signed in to change notification settings - Fork 107
6. Handling incoming shares
Kumar Bibek edited this page Mar 3, 2016
·
2 revisions
<activity
android:name=".MultiPickerShareActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<!-- Configure specific file types that you want to handle -->
<!-- <data android:mimeType="video/*" -->
<data android:mimeType="*/*"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE"/>
<!-- Configure specific file types that you want to handle -->
<!-- <data android:mimeType="image/*" -->
<data android:mimeType="*/*"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
</intent-filter>
</activity>
private void handleMultipleShares() {
if (type.startsWith("image")) {
ImagePicker picker = new ImagePicker(this);
picker.setImagePickerCallback(this);
picker.submit(IntentUtils.getPickerIntentForSharing(getIntent()));
} else if (type.startsWith("video")) {
VideoPicker picker = new VideoPicker(this);
picker.setVideoPickerCallback(this);
picker.submit(IntentUtils.getPickerIntentForSharing(getIntent()));
} else if (type.startsWith("application") || type.startsWith("file") || type.startsWith("*")) {
FilePicker picker = new FilePicker(this);
picker.setFilePickerCallback(this);
picker.submit(IntentUtils.getPickerIntentForSharing(getIntent()));
} else if (type.startsWith("audio")) {
AudioPicker picker = new AudioPicker(this);
picker.setAudioPickerCallback(this);
picker.submit(IntentUtils.getPickerIntentForSharing(getIntent()));
}
}
@Override
public void onImagesChosen(List<ChosenImage> images) {
// Display Images
}
@Override
public void onError(String message) {
// Handle error
}
@Override
public void onVideosChosen(List<ChosenVideo> videos) {
// Display Videos
}
@Override
public void onAudiosChosen(List<ChosenAudio> audios) {
// Display Audios
}
@Override
public void onFilesChosen(List<ChosenFile> files) {
// Display Files
}