Android-Use System albums to browse photos under the specified path

Source: Internet
Author: User


Open the System album Intent Intent=new Intent (intent.action_get_content); Intent.settype ("image/*"); StartActivity (intent);

Opens the specified photo Intent intent = new intent (); intent.setaction (Android.content.Intent.ACTION_VIEW); intent.setdataandtype (Uri.fromfile (Picturefilepath), "image/*"); StartActivity (intent);

Open System Album Browse photos Intent Intent = new Intent (Intent.action_view, Uri.parse ("Content://media/internal/images/media")); StartActivity (Intent);


Use mediascannerconnection Scan to develop image files under the path and start the system album to browse


A class written by myself

public class Picturescanner implements mediascannerconnection.mediascannerconnectionclient{private    Mediascannerconnection MMs;    Private File Mfile;    Private context context;    File[] Allfiles;        Public Picturescanner (Context context) {file folder = new File (Picturefolderpath);        Allfiles = Folder.listfiles ();        Swap (allfiles);        This.context = context;        Mfile = Allfiles[0];        MMs = new Mediascannerconnection (context, this);    Mms.connect ();    } public void onmediascannerconnected () {Mms.scanfile (Mfile.getabsolutepath (), NULL);        } public void onscancompleted (String path, Uri uri) {Intent Intent = new Intent (Intent.action_view);        Intent.setdata (URI);        Context.startactivity (Intent);    Mms.disconnect ();        } private void Swap (File a[]) {int len = a.length;            for (int i=0;i<len/2;i++) {File tmp = a[i];            A[i] = a[len-1-i];        A[len-1-i] = tmp;    }}} 

Call New Picturescanner (myactivity.this);



Android-Use System albums to browse photos under the specified path

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.