Deepak Jacob
Deepak Jacob

Reputation: 41

Open android Gallery App from react native app

My application requires opening an image, stored locally in the document directories using the android gallery app.Is this possible in react native using linking.

Upvotes: 0

Views: 1938

Answers (2)

Bv2124
Bv2124

Reputation: 61

Use this permission in AndroidManifest.XML

<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>

which can allow users to access the gallery to pick an image or video whenever we use the imagepicker.

We successfully used and solved this issue in our app ! so, Its working

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.nano.smartfm.reachv5">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION"/>
<queries>
<!--  Camera  -->
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE"/>
</intent>
<!--  Gallery  -->
<intent>
<action android:name="android.intent.action.GET_CONTENT"/>
<data android:mimeType="image/*"/>
</intent>
<intent>
<action android:name="android.intent.action.PICK"/>
<data android:mimeType="image/*"/>
</intent>
<intent>
<action android:name="android.intent.action.CHOOSER"/>
</intent>
<intent>
<action android:name="android.speech.RecognitionService"/>
</intent>
</queries>
<application android:requestLegacyExternalStorage="true" android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:theme="@style/AppTheme" android:usesCleartextTraffic="true" android:largeHeap="true">
<activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>
<meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyDoEK24faySzWqhom_1zsEzOXQiA5bx8pw"/>
<meta-data android:name="com.dieam.reactnativepushnotification.channel_create_default" android:value="false"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_foreground" android:value="true"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_color" android:resource="@android:color/white"/>
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions"/>
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher"/>
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver" android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
</intent-filter>
</receiver>
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
</application>
</manifest>

Upvotes: 0

Deepak Jacob
Deepak Jacob

Reputation: 41

So my requirement was to download an image on a button click an then open the same image using the android gallery , I achieved the same using react-native-fetch-blob which facilitates both downloading a file and opening it with the corresponding apps. P.S: you could also open the gallery using linking, provided you have the content url rather than file url.

Upvotes: 0

Related Questions