Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8784591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:08:00+00:00 2026-06-13T21:08:00+00:00

I’m trying to show images in the specific folder using default Android Gallery. I

  • 0

I’m trying to show images in the specific folder using default Android Gallery. I found only one sample code to do this. I have simplified that code and now it’s much clear:

public class ScanActivity extends Activity implements MediaScannerConnectionClient {

    private static final String SCAN_DIR = Environment.getExternalStorageDirectory() + File.separator + "MyFolder" + File.separator;
    private static final String FILE_TYPE="image/*";

    private String scanPath;
    private MediaScannerConnection conn;


    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

        scanPath = SCAN_DIR + new File(SCAN_DIR).list()[0];

        conn = new MediaScannerConnection(getApplicationContext(), this);
        conn.connect();
    }


    @Override
    public void onMediaScannerConnected()
    {
        conn.scanFile(scanPath, FILE_TYPE);
    }


    @Override
    public void onScanCompleted(String path, Uri uri)
    {
        try
        {
            if (uri != null) 
            {
                //uri = content://media/external/images/media/11271
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setDataAndType(uri, FILE_TYPE);
                startActivity(intent);
            }
        }
        finally
        {
            conn.disconnect();
            conn = null;
        }
    }

}

On Android Froyo (2.2) it works OK – the gallery opens all images in MyFolder directory, but on Jelly Bean (4.1) I see just black screen (see the screenshot below). Of course scanned folder contains photos on both devices.

screenshot 4.1

The logcat output:

11-03 18:31:31.872: W/DataManager(12540): exception in creating media object: /local/image/item/11271
11-03 18:31:31.872: W/DataManager(12540): java.lang.RuntimeException: cannot find data for: /local/image/item/11271
11-03 18:31:31.872: W/DataManager(12540):   at com.android.gallery3d.data.LocalImage.<init>(LocalImage.java:104)
11-03 18:31:31.872: W/DataManager(12540):   at com.android.gallery3d.data.LocalSource.createMediaObject(LocalSource.java:106)
11-03 18:31:31.872: W/DataManager(12540):   at com.android.gallery3d.data.DataManager.getMediaObject(DataManager.java:165)
11-03 18:31:31.872: W/DataManager(12540):   at com.android.gallery3d.data.LocalSource.getDefaultSetOf(LocalSource.java:183)
11-03 18:31:31.872: W/DataManager(12540):   at com.android.gallery3d.data.DataManager.getDefaultSetOf(DataManager.java:261)
11-03 18:31:31.872: W/DataManager(12540):   at com.android.gallery3d.app.Gallery.startViewAction(Gallery.java:198)
11-03 18:31:31.872: W/DataManager(12540):   at com.android.gallery3d.app.Gallery.initializeByIntent(Gallery.java:91)
11-03 18:31:31.872: W/DataManager(12540):   at com.android.gallery3d.app.Gallery.onCreate(Gallery.java:68)
11-03 18:31:31.872: W/DataManager(12540):   at android.app.Activity.performCreate(Activity.java:5008)
11-03 18:31:31.872: W/DataManager(12540):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
11-03 18:31:31.872: W/DataManager(12540):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
11-03 18:31:31.872: W/DataManager(12540):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
11-03 18:31:31.872: W/DataManager(12540):   at android.app.ActivityThread.access$600(ActivityThread.java:143)
11-03 18:31:31.872: W/DataManager(12540):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
11-03 18:31:31.872: W/DataManager(12540):   at android.os.Handler.dispatchMessage(Handler.java:99)
11-03 18:31:31.872: W/DataManager(12540):   at android.os.Looper.loop(Looper.java:137)
11-03 18:31:31.872: W/DataManager(12540):   at android.app.ActivityThread.main(ActivityThread.java:4965)
11-03 18:31:31.872: W/DataManager(12540):   at java.lang.reflect.Method.invokeNative(Native Method)
11-03 18:31:31.872: W/DataManager(12540):   at java.lang.reflect.Method.invoke(Method.java:511)
11-03 18:31:31.872: W/DataManager(12540):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
11-03 18:31:31.872: W/DataManager(12540):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
11-03 18:31:31.872: W/DataManager(12540):   at dalvik.system.NativeStart.main(Native Method)
11-03 18:31:31.872: V/StateManager(12540): startState class com.android.gallery3d.app.PhotoPage
11-03 18:31:31.911: V/NFC(12540): this device does not have NFC support
11-03 18:31:32.044: W/DecodeService(12540): java.lang.NullPointerException
11-03 18:31:32.044: W/DecodeService(12540):     at java.io.File.fixSlashes(File.java:185)
11-03 18:31:32.044: W/DecodeService(12540):     at java.io.File.<init>(File.java:134)
11-03 18:31:32.044: W/DecodeService(12540):     at java.io.FileInputStream.<init>(FileInputStream.java:105)
11-03 18:31:32.044: W/DecodeService(12540):     at com.android.gallery3d.data.DecodeUtils.decodeThumbnail(DecodeUtils.java:92)
11-03 18:31:32.044: W/DecodeService(12540):     at com.android.gallery3d.data.LocalImage$LocalImageRequest.onDecodeOriginal(LocalImage.java:188)
11-03 18:31:32.044: W/DecodeService(12540):     at com.android.gallery3d.data.ImageCacheRequest.run(ImageCacheRequest.java:74)
11-03 18:31:32.044: W/DecodeService(12540):     at com.android.gallery3d.data.LocalImage$LocalImageRequest.run(LocalImage.java:154)
11-03 18:31:32.044: W/DecodeService(12540):     at com.android.gallery3d.data.ImageCacheRequest.run(ImageCacheRequest.java:28)
11-03 18:31:32.044: W/DecodeService(12540):     at com.android.gallery3d.util.ThreadPool$Worker.run(ThreadPool.java:124)
11-03 18:31:32.044: W/DecodeService(12540):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
11-03 18:31:32.044: W/DecodeService(12540):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
11-03 18:31:32.044: W/DecodeService(12540):     at java.lang.Thread.run(Thread.java:856)
11-03 18:31:32.044: W/DecodeService(12540):     at com.android.gallery3d.util.PriorityThreadFactory$1.run(PriorityThreadFactory.java:43)
11-03 18:31:32.044: W/ImageCacheRequest(12540): decode orig failed /local/image/item/11271,THUMB

I googled and found no information about this exception.

I’m really confused about this problem and don’t know how to fix it. Does anyone have idea how to fix it? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:08:01+00:00Added an answer on June 13, 2026 at 9:08 pm

    It seems that I found problem. Changing line

    conn.scanFile(scanPath, FILE_TYPE);
    
    //what is ectualy equals to:
    //conn.scanFile(scanPath, "image/*");
    

    to this line:

    conn.scanFile(scanPath, null);
    

    fixed a problem. I’m not sure but this seems to be an Android bug.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.