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

  • Home
  • SEARCH
  • 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 7643397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:26:22+00:00 2026-05-31T09:26:22+00:00

I have the following code; String[] projection = { MediaStore.Video.VideoColumns._ID, MediaStore.Video.VideoColumns.DATA }; //String selection

  • 0

I have the following code;

String[] projection = { MediaStore.Video.VideoColumns._ID, MediaStore.Video.VideoColumns.DATA };
                //String selection = MediaStore.Video.VideoColumns.KIND + "=" + MediaStore.Video.VideoColumns.;
                String sort = MediaStore.Video.VideoColumns._ID + " DESC";

                Cursor myCursor = getActivity().managedQuery(MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI, projection, null, null, sort);


                try
                {
                    myCursor.moveToFirst();
                    Log.d("VIDEO_URI", intent.getDataString());
                    Bitmap bitmap = MediaStore.Video.Thumbnails.getThumbnail(
                            getActivity().getContentResolver(), myCursor.getLong(myCursor.getColumnIndexOrThrow(MediaStore.Video.VideoColumns._ID)),
                            MediaStore.Video.Thumbnails.MICRO_KIND,
                            (BitmapFactory.Options) null );

                    ImageView iv = (ImageView) getActivity().findViewById(R.id.attached_media_image);

                    //Log.d("IMAGE", curThumb.toString());

                    iv.setImageBitmap(bitmap);

                }
                catch (Exception e) {
                    // TODO: handle exception
                    Log.e("ERROR", e.toString());
                }

I get the following in my LogCat when this is ran;

03-13 12:05:14.740: D/VIDEO_URI(7269): content://media/external/video/media/474

But it doesn’t set the image of the iv to anything, and when I try to run the Log.d(“IMAGE”, curThumb.toString()); line, that is commented out in this example, it throws a null exception.

Any help would be much appreciated thank you.

  • 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-05-31T09:26:23+00:00Added an answer on May 31, 2026 at 9:26 am

    The thumbnail generation is not guaranteed to succeed since the part that generates thumbnails cannot do so for some video codecs. The returned Bitmap will be null in that case.

    • Have you checked if bitmap != null?
    • Do you get a thumbnail for the Video in e.g. the Gallery app?
    • What is curThumb, I can see no definition of that in your code.

    Edit: Your error is that you use the ID from the thumbnails table not the id of the video.
    All you need to do is to get the Bitmap this way:

            Bitmap bitmap = MediaStore.Video.Thumbnails.getThumbnail(
                    getActivity().getContentResolver(),
                    ContentUris.parseId(intent.getData()),
                    MediaStore.Video.Thumbnails.MICRO_KIND,
                    (BitmapFactory.Options) null );
    

    Api Doc says: “origId: Original image id associated with thumbnail of interest.”

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

Sidebar

Related Questions

I have following code in pre-Android2.0 API: String[] PROJECTION = new String[] { Contacts.People._ID,
Cursor cursor = resolver.query( Data.CONTENT_URI, DataQuery.PROJECTION, DataQuery.SELECTION, new String[] {String.valueOf(rawContactId)}, null); With PROJECTION being:
I have the following code: String inputFile = somefile.txt; FileInputStream in = new FileInputStream(inputFile);
I have the following code string three() { return three; } void mutate(string& ref)
I have the following code: string acctStatus = account.AccountStatus.ToString(); if (!SettableStatuses().Any(status => status ==
I have the following code: String serviceType; ServiceBrowser tmpBrowser; for (String playerName: players) {
I have the following code: string[] firstArray = { bla bla, bla bla, bla
currently I have the following code: String select = qry.substring(select .length(),qry2.indexOf( from )); String[]
Ok so I have the following code: string numbers = File.ReadAllText(numbers.txt); StringSplitOptions.RemoveEmptyEntries); List<string> List
Follow up to this question . I have the following code: string[] names =

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.