[英]ionic android : when choose image from gallery the app crash
當我單擊choose file(input="file")
以從圖庫中選擇圖像時,在android上選擇圖像后,應用程序崩潰了,在ios(iphone)上也是如此。 我已經在androidmanifest.xml上添加了權限:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-feature android:name="android.hardware.camera.autofocus" />
仍然無法正常工作。
我在iOS中遇到了同樣的問題。 嘗試將這些數據添加到info.plist
<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires access to the photo library.</string>
<key>NSCameraUsageDescription</key>
<string>This app requires access to the camera.</string>
對於android,您可以共享logcat輸出。
如果使用了phonegap,請問您可以分享ID嗎?
如果僅定位圖像,建議您使用Cordova / Ionic Native插件,而不要使用文件輸入。 這將更容易,您將獲得更多訪問圖像及其屬性的控制權。 您可以使用Camera插件或Photo Library Plugin 。 您可以使用requestAuthorization
函數向用戶請求權限。
您可能需要在config.xml中添加權限。 例如,如Camera Plugin Ionic頁面中所述
[警告]由於IOS 10,攝像機需要將權限放置在config.xml中添加
<config-file parent="NSCameraUsageDescription" platform="ios" target="*-Info.plist"><string>You can take photos</string></config-file>
請注意,最好是將所有權限都包含在config.xml文件中,而不要包含在AndroidManifest.xml / info.plist中,因為一旦在本機平台上添加/運行構建后,它將始終自動添加。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.