Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): implement Android Photo Picker #14131

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Oct 3, 2024

Will replace the current openPhotoGallery method and use https://developer.android.com/training/data-storage/shared/photopicker

When I was updating an Android app I was asked in the store to use the Photo Picker instead of using <uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>. But you could still opt-in for the image permission, so not a high priority for now.

I have to call ActivityResultLauncher in the BaseActivity otherwise I wasn't able to catch the results. And in order to get the results from the BaseActivity back to MediaModule I use a local Broadcast. Not sure if that is the best way to do it but I didn't find another way.

var win = Ti.UI.createWindow();
var img = Ti.UI.createImageView();
win.addEventListener("click", function() {

	Ti.Media.openPhotoGallery({
		allowMultiple:true,
		mediaTypes: Titanium.Media.MEDIA_TYPE_PHOTO, // Titanium.Media.MEDIA_TYPE_VIDEO
		success: function(e) {
			img.image = e.media;
		}
	});

})
win.add(img);
win.open();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant