我有Android應用程序,其中一個登錄Facebook用戶檢索您的Android應用程序中的所有他的朋友以類似的方式與此圖片: http://i55.tinypic.com/wv9vzb.png(這是取自iPhone,但我想要類似的東西對此)。在Android應用程序中檢索用戶的朋友
我已經使用facebook-sdk將facebook集成到了我的應用程序中。
如果有人能指出我正確的方向,我會gratefull.Thanks!
UPDATE:
我想與您的代碼加載網址:
Bitmap bitmap=null;
Log.d("We are:","Loading Picture");
imageURL = "http://graph.facebook.com/"+userID+"/picture?type=small";
try{
bitmap=BitmapFactory.decodeStream((InputStream)new URL(imageURL).getContent());
}catch(Exception e){
Log.d("And:","Loading Picture FAILED");
e.printStackTrace();
}
而且logcat的是這樣的:
java.net.SocketTimeoutException: The operation timed out
at org.apache.harmony.luni.platform.OSNetworkSystem.receiveStreamImpl(Native Method)
at org.apache.harmony.luni.platform.OSNetworkSystem.receiveStream(OSNetworkSystem.java:478)
at org.apache.harmony.luni.net.PlainSocketImpl.read(PlainSocketImpl.java:565)
at org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:61)
at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.readln(HttpURLConnection.java:1178)
at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.readServerResponse(HttpURLConnection.java:1250)
at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.sendRequest(HttpURLConnection.java:1238)
at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.doRequestInternal(HttpURLConnection.java:1558)
at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.doRequest(HttpURLConnection.java:1551)
at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1052)
at java.net.URLConnection$DefaultContentHandler.getContent(URLConnection.java:1053)
at java.net.URLConnection.getContent(URLConnection.java:166)
at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnection.getContent(HttpsURLConnection.java:156)
at java.net.URL.getContent(URL.java:621)
at com.facebook.android.Example.getUserPic(Example.java:192)
at com.facebook.android.Example$2.onClick(Example.java:174)
at android.view.View.performClick(View.java:2364)
at android.view.View.onTouchEvent(View.java:4179)
at android.widget.TextView.onTouchEvent(TextView.java:6540)
at android.view.View.dispatchTouchEvent(View.java:3709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
我必須說,當我鍵入URL瀏覽器會顯示正確的個人資料圖片。
我想也做了http post
加載網址:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost=new HttpPost(imageURL);
try{
HttpResponse response = httpclient.execute(httppost);
if(response!=null)
{
bitmap=BitmapFactory.decodeStream(response.getEntity().getContent());
}
}
catch(ClientProtocolException e)
{
e.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
}
而且logcat的是這樣的:
Uncaught handler: thread main exiting due to uncaught exception
java.lang.IllegalArgumentException: Host name may not be null
at org.apache.http.HttpHost.<init>(HttpHost.java:83)
at org.apache.http.impl.client.AbstractHttpClient.determineTarget(AbstractHttpClient.java:497)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
at com.facebook.android.Example.getUserPic(Example.java:203)
at com.facebook.android.Example$2.onClick(Example.java:174)
at android.view.View.performClick(View.java:2364)
at android.view.View.onTouchEvent(View.java:4179)
at android.widget.TextView.onTouchEvent(TextView.java:6540)
at android.view.View.dispatchTouchEvent(View.java:3709)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
什麼問題: - ?s
我不太清楚看去在日誌裏是什麼導致了錯誤,我從來沒有「權威期望在索引7」的例外!如果你願意,你可以壓縮這個項目,發佈一個鏈接,我會下載它,看看我能不能解決問題是什麼? – Kenny
我嘗試的例子是facebook-sdk的一個.....我應該壓縮一切...還是隻有我嘗試過這些東西的課程?你想運行這個項目嗎? – adrian
http://dl.transfer.ro/simple-transfer_RO-16jul-7b53ea.zip如果你要運行它:首先按請求按鈕,然後請求配置文件圖片!按鈕,謝謝你! – adrian