Melt Cloud Android SDK photo, image selector scheme analysis

Source: Internet
Author: User

A photo

There are two options for photo-melting and cloud


1 The camera key class that comes with the SDK Kit package: Camerainputprovider

This type of click is to evoke the takingpicturesactivity feature is to take a photo after the tick is completed there will be a preview interface this scenario if you click on some models on the tick and no response is because

Some models evoke the system camera and then recycle the following stack resources have been done onsaveinstancestate life cycle save instantaneous state but this is still the case

Post implementation code below if you have a developer who knows the ultimate solution to this problem, please leave a message or contact the author

public class Takingpicturesactivity extends Activity implements View.onclicklistener {private final static int REQUEST    _camera = 0x2;    Private ImageView mimage;    Private Uri Msavedpicuri;        @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);        Requestwindowfeature (Window.feature_no_title);        Setcontentview (R.layout.rc_ac_camera);        button Cancel = (Button) Findviewbyid (R.id.rc_back);        button send = (Button) Findviewbyid (r.id.rc_send);        Mimage = (ImageView) Findviewbyid (r.id.rc_img);        Cancel.setonclicklistener (this);        Send.setonclicklistener (this);        RLOG.D (This, "OnCreate", "savedinstancestate:" + savedinstancestate);        if (savedinstancestate = = null) {Startcamera ();            } else {String str = savedinstancestate.getstring ("Photo_uri");                if (str! = null) {Msavedpicuri = Uri.parse (str);                   try { Mimage.setimagebitmap (Bitmaputil.getresizedbitmap (this, Msavedpicuri, 960, 960));                } catch (IOException e) {e.printstacktrace (); }}}} @Override public void onconfigurationchanged (Configuration newconfig) {Super.on    Configurationchanged (Newconfig);        } @Override public void OnClick (View v) {Final file File = new file (Msavedpicuri.getpath ());        if (!file.exists ()) {finish (); if (v.getid () = = R.id.rc_send) {if (Msavedpicuri! = null) {Intent data = new Intent ()                ;                Data.setdata (Msavedpicuri);            Setresult (RESULT_OK, data);        } finish ();        } else if (v.getid () = = R.id.rc_back) {finish ();        }} private void Startcamera () {Intent Intent = new Intent ();        Intent.setaction (mediastore.action_image_capture); File Path = Environment.getexternalstorAgepublicdirectory (Environment.directory_pictures);        String name = System.currenttimemillis () + ". jpg";        File File = new file (path, name);        Msavedpicuri = uri.fromfile (file);        RLOG.D (This, "Startcamera", "output pic uri =" + Msavedpicuri);        Intent.putextra (Mediastore.extra_output, Msavedpicuri);        Intent.addcategory (Intent.category_default);    Startactivityforresult (Intent, Request_camera); } @Override public void Onactivityresult (int requestcode, int. ResultCode, final Intent data) {RLOG.D (this, "        Onactivityresult "," ResultCode = "+ ResultCode +", intent= "+ data);            if (resultcode! = ACTIVITY.RESULT_OK) {finish ();        Return                    } switch (requestcode) {case Request_camera:if (ResultCode = = result_canceled) {                    Finish ();                LOG.E ("Takingpicturesactivity", "result_canceled"); } if (Msavedpicuri! = null && ResultCode = = ACTIVITY.RESULT_OK) {try{Mimage.setimagebitmap (bitmaputil                    . Getresizedbitmap (This, Msavedpicuri, 960, 960));                    } catch (IOException e) {e.printstacktrace ();            }} break;        Default:return;    } super.onactivityresult (Requestcode, ResultCode, data); } @Override protected void Onrestoreinstancestate (Bundle savedinstancestate) {//Restore LOG.E ("takingpictu        Resactivity "," onrestoreinstancestate ");        Msavedpicuri = Uri.parse (savedinstancestate.getstring ("Photo_uri"));    Super.onrestoreinstancestate (savedinstancestate); } @Override public void Onsaveinstancestate (Bundle outstate) {//Save LOG.E ("Takingpicturesactivity", "on        Saveinstancestate ");        Outstate.putstring ("Photo_uri", msavedpicuri.tostring ());    Super.onsaveinstancestate (outstate); }}


2 Newcamerainputprovider in the Demo code

When this kind of photo is finished, the direct tick indicates that there is no preview interface code for the session interface. Currently in the Cloud website Demo has open source Io/rong/app/provider/newcamerainputprovider.java


If you choose the switch mode of scenario two:

1 Copy the Io/rong/app/provider/newcamerainputprovider.java in the Demo to your project note some details of resource files, etc.

2 Setting the custom session interface enter the bar + number feature to customize the registration of Newcamerainputprovider details see


Here's an explanation of the first array that you need to show which function modules are set below the code that you need to define the array function module in which session types are shown here to remind the voice function

VoIP only supports single-to-single setup this time after Rongim.init initialization

Okay, all right. The above article has made a detailed narration of the two schemes and usages of taking pictures. If there are any details that are not mentioned welcome message Spit Groove


Two albums

Current Cloud album also provides two kinds of solution support: JPEG PNG jpg bmp and other picture formats

1:SDK Kit default comes with Imageinputprovider

Functional analysis: The effect is very smooth loading speed also quickly support unlimited multi-select picture send and preview, the disadvantage is that all the pictures in the phone in a GridView display

No multiple folder selection and recent photos

2:demo Photo Package under code Open source Core class Photocollectionsprovider

Function Analysis: Using Lruche cache technology to speed up the loading speed of the space-changing fast support multi-photo folder selection Support Recent photo-pinned sort codes open source can be based on their

Changes to business requirements


How to use photo album Scenario 2:

1 Copy the entire package of the Demo photo to your project modify the package name remember that the resource files and pictures are also copied


2 Refer to the picture that is called the image settings Photocollectionsprovider can be


Picture selection Here there is a robust problem that is not resolved interested can refer to http://blog.csdn.net/qq_19986309/article/details/47080287

If there is a solution to pre-verify the validity of the picture please contact the author or leave a message to be appreciated


RELATED LINKS finally can be based on the + Number function module to customize their own to develop such as photo album map and other functions if there is a better development of functional modules such as Baidu High-German map positioning or more optimization

Photo Album selection of modules willing to open source benefits broad cloud developers please contact me message welcome pull request! end~


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Melt Cloud Android SDK photo, image selector scheme analysis

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.