This SDK use apache.http lib and json lib.
import com.facepp.*;
or
AutoComplete it with your editor or IDE.
create a com.facepp.http.HttpRequests object
HttpRequests httpRequests = new HttpRequests(you_api_key_string, you_api_secret_string);
create a com.facepp.http.PostParameters object with all parameters
PostParameters postParameters = new PostParameters().setUrl("http://faceplusplus.com/static/img/demo/8.jpg").setAttribute("all");
request
httpRequests.request("detection", "detect", postParameters);
or
httpRequests.detectionDetect(postParameters);
get the result use the com.facepp.json.FaceppJson object
FaceppResult result = httpRequests.detectionDetect(postParameters);
Example:
result.get("face").getCount()
result.get("face").get(0).get("face_id").toString()
result.get("face").get(0).get("").toString("attribute").get("gender").get("confidence").toDouble()
View the post request
postParameters.getMultiPart().writeTo(System.out);
View the result like a pure json
System.out.println(result)
a sample about multipart http post message
--0soLYaK4lNBytrh912fNS15mSORsgy_J
Content-Disposition: form-data; name="person_name"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
my_person_name
--0soLYaK4lNBytrh912fNS15mSORsgy_J
Content-Disposition: form-data; name="group_name"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
my_group_name
--0soLYaK4lNBytrh912fNS15mSORsgy_J--
note that you can not requst on MainActivity, you need to new a thread to do what you want
note that you need add internet uses-permission into AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET"/>
FaceppDemo
An Java project with FaceppSDK
FaceppAndroidDemo
An Android project with FaceppSDK
PictureDetect
An Android application. To get a picture, detect with FaceppSDK, then mark all faces out.