npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-android-image-picker

v0.1.3

Published

Uploading photos from the gallery on Android

Readme

react-native-android-image-picker

A lightweight and easy-to-use React Native module for selecting multiple images from the Android gallery. Supports both default UI and custom children components. Returns URI, Base64, Size, and MimeType.

Installation

npm install react-native-android-image-picker

Android Setup (Important)

Add the following permissions to your android/app/src/main/AndroidManifest.xml file:

<manifest ...>
    <!-- Required for reading images from gallery -->
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
    ...
</manifest>

Usage

Here is a complete example including imports and state management.

import React, { useState } from 'react';
import { StyleSheet, View, Text, Image, ScrollView } from 'react-native';
import { ImagePicker } from 'react-native-android-image-picker';

export default function App() {
  const [images, setImages] = useState([]);

  const handleSelect = (files) => {
    console.log('Selected Files:', files);
    setImages(files);
  };

  const handleError = (err) => {
    console.error('Error:', err);
  };

  return (
    <ScrollView contentContainerStyle={styles.container}>
      <Text style={styles.header}>Android Image Picker</Text>

      {/* 1. Default UI Usage */}
      <Text style={styles.subHeader}>Default Appearance:</Text>
      <ImagePicker
        maxImage={2} // Select max 2 images
        onSelect={handleSelect}
        onError={handleError}
        style={styles.defaultButton}
      />

      <View style={styles.separator} />

      {/* 2. Custom UI Usage */}
      <Text style={styles.subHeader}>Custom Child Component:</Text>
      <ImagePicker
        maxImage={5} // Select max 5 images
        onSelect={handleSelect}
        onError={handleError}
      >
        <View style={styles.customButton}>
          <Text style={styles.customButtonText}>📸 Select Photos (Max 5)</Text>
        </View>
      </ImagePicker>

      {/* Display Selected Images */}
      <View style={styles.resultContainer}>
        {images.map((img, index) => (
          <View key={index} style={styles.imageCard}>
            <Image source={{ uri: img.uri }} style={styles.previewImage} />
            <View style={styles.infoContainer}>
              <Text numberOfLines={1} style={styles.infoText}>📍 URI: {img.uri}</Text>
              <Text style={styles.infoText}>💾 Size: {(img.size / 1024).toFixed(2)} KB</Text>
              <Text style={styles.infoText}>📄 Type: {img.type}</Text>
              <Text style={styles.infoText}>🔐 Base64: {img.base64 ? "Available" : "N/A"}</Text>
            </View>
          </View>
        ))}
      </View>
    </ScrollView>
  );
}

const styles = StyleSheet.create({
  container: {
    padding: 20,
    backgroundColor: '#f2f2f2',
    flexGrow: 1,
  },
  header: {
    fontSize: 20,
    fontWeight: 'bold',
    marginBottom: 20,
    textAlign: 'center',
    color: '#333',
  },
  subHeader: {
    fontSize: 14,
    fontWeight: '600',
    marginBottom: 10,
    marginTop: 10,
    color: '#555',
  },
  separator: {
    height: 1,
    backgroundColor: '#ccc',
    marginVertical: 20,
  },
  defaultButton: {
    backgroundColor: '#ddd',
    padding: 10,
    borderRadius: 8,
    alignItems: 'center',
  },
  customButton: {
    backgroundColor: '#6200ee',
    padding: 15,
    borderRadius: 30,
    alignItems: 'center',
    elevation: 3,
  },
  customButtonText: {
    color: '#fff',
    fontWeight: 'bold',
  },
  resultContainer: {
    marginTop: 20,
  },
  imageCard: {
    flexDirection: 'row',
    backgroundColor: '#fff',
    padding: 10,
    borderRadius: 8,
    marginBottom: 10,
    elevation: 2,
  },
  previewImage: {
    width: 60,
    height: 60,
    borderRadius: 8,
    backgroundColor: '#eee',
  },
  infoContainer: {
    marginLeft: 10,
    flex: 1,
    justifyContent: 'center',
  },
  infoText: {
    fontSize: 10,
    color: '#444',
  }
});

API Reference

Props

| Prop | Type | Default | Description | |---|---|---|---| | maxImage | number | 1 | Maximum number of images user can select. | | onSelect | function | Required | Callback function that returns an array of selected images. | | onError | function | Optional | Callback function for error handling. | | style | ViewStyle | Optional | Styles for the touchable container (if using default UI). | | children | ReactNode | Optional | Custom component to render inside the touchable area. |

Response Object

The onSelect callback returns an array of objects with the following structure:

[
  {
    uri: "content://media/external/...", // The image URI
    type: "image/jpeg",                  // Mime type
    size: 45032,                         // Size in bytes
    base64: "/9j/4AAQSkZJRg..."          // Base64 string of the image
  }
]

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT