upload picture to emulator gallery

前端 未结 8 1005
闹比i
闹比i 2020-12-02 20:12

I want to add picture in emulator\'s gallery. But i am not able to do this. How to do this? any clue! Though i have gone through a answer posted in stack over flow but didn\

8条回答
  •  南笙
    南笙 (楼主)
    2020-12-02 20:55

    First thing to do is to get the image(s) at the storage of the emulator. For this you have several options. I'll list the most common options here. But first an important note on the need to scan for this media on the emulator. As pointed out by Felby in another answer.

    Where to put the images

    The standard location (for the devices I've tested so far) where images from the camera are put on the device is /mnt/sdcard/DCIM/100ANDRO.

    However since we need to scan manually anyway you can put them at /mnt/sdcard/Pictures or any other valid path on the (emulated) sdcard.

    The /sdcard/ path is linked to /mnt/sdcard/ so that will also work. I'm just mentioning this because I've seen this path on another answer.

    How to upload images to emulator

    Using adb

    For hardcore users, execute the adb push from command line. If you don't know how to work with adb I can recommend reading up on this help article. Make sure you have the path set correctly for your system and adb devices returns at least one device (if more specify device in command).

    adb push /path/to/image.jpg /mnt/sdcard/DCIM/100ANDRO
    

    Using eclipse (ADT)

    You can achieve the same by clicking some buttons in ADT. Go to the DDMS perspective and in the file explorer select the icon on the top. Check image below for details.

    enter image description here

    image linked from http://cdn.cybersectors.com/

    Scan for media

    An important step not to forget is executing this tool on the Android Emulator. If you skip this the Gallery will remain empty. Many thanks to Felby for pointing this out.

    I then had to go into the running emulator itself, select "Dev Tools" from the Apps screen, the select "Media Scanner" (or "Media Provider" in newer versions of Android) to get the emulator to recognize the files so they would be displayed in the Media Gallery.

提交回复
热议问题