I have got all the facebook albums (and their id )using facebook android sdk, and displayed them in a list. Now on particular list item click, i want to get all the photos of that album (wrt "id" )
I got album id this way:
if (!facebook.isSessionValid()) {
facebook.authorize(this, new String[] { "user_photos" },
new DialogListener() {
public void onComplete(Bundle values) {
mAsyncRunner.request("me/albums", new albumsRequestListener());
}
public void onFacebookError(FacebookError error) {
}
public void onError(DialogError e) {
}
public void onCancel() {
}
});
}
public class albumsRequestListener implements RequestListener {
public void onComplete(String response, Object state) {
// TODO Auto-generated method stub
try {
Log.d("Facebook-Example", "Response: " + response.toString());
JSONObject json = Util.parseJson(response);
String count = "0";
JSONArray jArrData = new JSONArray();
jArrData = json.getJSONArray("data");
for (int i = 0; i < jArrData.length(); i++) {
JSONObject objAlbum = jArrData.getJSONObject(i);
String albumId = objAlbum
.getString("id");
String albumName = objAlbum
.getString("name");
if(objAlbum.has("count"))
{
count = objAlbum.getString("count");
}
else
{
count = "0";
}
FbAlbums obj = new FbAlbums();
obj.setId(albumId);
obj.setName(albumName);
obj.setCount(count);
listFbAlbums.add(obj);
}
FB.this.runOnUiThread(new Runnable() {
public void run() {
adapter = new FbAlbumsListAdapter(
getApplicationContext(),listFbAlbums);
lvAlmbums.setAdapter(adapter);
pb.setVisibility(View.INVISIBLE);
lvAlmbums.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(getApplicationContext(), position, Toast.LENGTH_SHORT).show();
}
});
}
});
} catch (JSONException e) {
Log.w("Facebook-Example", "JSON Error in response");
} catch (FacebookError e) {
Log.w("Facebook-Example", "Facebook Error: " + e.getMessage());
}
}
public void onIOException(IOException e, Object state) {
// TODO Auto-generated method stub
}
public void onFileNotFoundException(FileNotFoundException e,
Object state) {
// TODO Auto-generated method stub
}
public void onMalformedURLException(MalformedURLException e,
Object state) {
// TODO Auto-generated method stub
}
public void onFacebookError(FacebookError e, Object state) {
// TODO Auto-generated method stub
}
}
How can i get the json that contains source of each album's images? Or is there some other way? Any help will be appreciated, Thanks
只需使用相册ID并在最后添加/ photos:
mAsyncRunner.request(albumid+"/photos", new photosRequestListener());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.