How to add an image to the emulator gallery in android studio?

后端 未结 11 1652
囚心锁ツ
囚心锁ツ 2020-12-13 05:38

I am developing an image filter app. But can\'t really try it if i don\'t have any images.

I know that i can test it in the phone, but it\'s not the same, since I n

相关标签:
11条回答
  • 2020-12-13 06:15

    Although you can have logat on a real device too, if you need to use an emulator try transferring the images through the Android Device Monitor, accessible from the toolbar in Android Studio (it's in eclipse too, of course).

    Once you select the device from ADM, you can see the folders tree and copy things inside

    0 讨论(0)
  • 2020-12-13 06:16

    I'd like to complement Mithilesh Izardar's answer:

    Indeed the best approach is simply to "Drag and Drop", which afterwards you can find the files in the emulator at Settings → Storage → Internal Storage → Explore → Download (API 25). The problem for me was that after following these steps the pics weren't appearing neither in the "Gallery" nor in the "Downloads" (by simply clicking the "Downloads" icon).

    The reason for this is because by default everything in the emulator has no permissions...so all you gotta do is give the "Gallery" storage permission: Settings → Apps → Gallery → Permissions (API 25)

    Ps: If you just copied the pictures, the new ones won't show up right away. You should either restart the emulator, or remount the sdcard (at Settings → Storage unmount the sdcard by clicking the eject icon then remount it)

    0 讨论(0)
  • 2020-12-13 06:16

    Copy a file to the emulator:

    Open emulator and File Explorer (Finder in Mac) side by side. Choose the file you want to copy then Drag and Drop the file onto the emulator. The selected file will be copied to the Downloads folder of the emulator.

    How to view files in Android Studio:

    Android Studio has Device Explorer to explore emulator content (Earlier we used to have DDMS, which is deprecated in Studio 3+). Goto View -> Tools Window -> Device File Explorer and you can see the explorer window. Goto Storage -> emulated -> 0 ->Download, if you don't see the file here, please restart the emulator and that's it.

    Note: You don't see Device Explorer if you have opened a Flutter project.

    You can also view the image files in Android Studio by double-clicking the file in the emulator.

    0 讨论(0)
  • 2020-12-13 06:18

    After trying to add an image via the Device Monitor or via drop, I could find it when exploring, but it was still not shown in the Gallery.

    For me, it helped to eject the (virtual) sdcard from Settings > Storage & USB and reinserting it.

    0 讨论(0)
  • 2020-12-13 06:20

    I had the same problem too. I used this code:

    Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
    photoPickerIntent.setType("image/*");
    startActivityForResult(photoPickerIntent, SELECT_PHOTO);
    

    Using the ADM, add the images on the sdcard or anywhere.

    And when you are in your vm and the selection screen shows up, browse using the top left dropdown seen in the image below.

    0 讨论(0)
提交回复
热议问题