每次我在模擬器上測試我的應用程序。 「AppName發生錯誤,請稍後再試。」我在清單.XML中啓用了互聯網訪問。Android上的Facebook OAuth
這是我到目前爲止有:
package com.xxxxxx;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import com.facebook.android.DialogError;
import com.facebook.android.Facebook;
import com.facebook.android.Facebook.DialogListener;
import com.facebook.android.FacebookError;
import com.facebook.android.Util;
public class LunchtimeActivity extends Activity {
Facebook facebook = new Facebook("xxxxxxxxxxxxxx");
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
facebook.authorize(this, new String [] {"user_location", "friend_location", "user_events", "friends_events"}, new DialogListener() {
@Override
public void onComplete(Bundle values) {}
@Override
public void onFacebookError(FacebookError error) {}
@Override
public void onError(DialogError e) {}
@Override
public void onCancel() {}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name");
try {
String response = facebook.request("me/friends", parameters);
JSONObject json = Util.parseJson(response);
JSONArray data = json.getJSONArray("data");
for (int i = 0; i < data.length(); i++)
{
JSONObject friend = data.getJSONObject(i);
String id = friend.getString("id");
String name = friend.getString("name");
Log.v("JSON", id);
Log.v("JSON", name);
}
}
catch (Exception e) {}
catch (FacebookError f) {}
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
facebook.authorizeCallback(requestCode, resultCode, data);
}
}
logcat的輸出:
...
05-01 02:21:01.601: DEBUG/Facebook-WebView(234): Webview loading URL: fbconnect://success/?error=invalid_scope&error_description=Unsupported+scope%3A+%27friend_location...
Eclipse控制檯輸出:
[2011-05-01 02:18:57 - Lunchtime_1.0] ------------------------------
[2011-05-01 02:18:57 - Lunchtime_1.0] Android Launch!
[2011-05-01 02:18:57 - Lunchtime_1.0] adb is running normally.
[2011-05-01 02:18:57 - Lunchtime_1.0] Performing com.lunch.LunchtimeActivity activity launch
[2011-05-01 02:18:57 - Lunchtime_1.0] Automatic Target Mode: Preferred AVD 'Now' is not available. Launching new emulator.
[2011-05-01 02:18:57 - Lunchtime_1.0] Launching a new emulator with Virtual Device 'Now'
[2011-05-01 02:19:03 - Emulator] 2011-05-01 02:19:03.471 emulator[3575:903] Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz.
[2011-05-01 02:19:03 - Lunchtime_1.0] New emulator found: emulator-5554
[2011-05-01 02:19:03 - Lunchtime_1.0] Waiting for HOME ('android.process.acore') to be launched...
[2011-05-01 02:20:20 - Lunchtime_1.0] WARNING: Application does not specify an API level requirement!
[2011-05-01 02:20:20 - Lunchtime_1.0] Device API version is 7 (Android 2.1-update1)
[2011-05-01 02:20:20 - Lunchtime_1.0] HOME is up on device 'emulator-5554'
[2011-05-01 02:20:20 - Lunchtime_1.0] Uploading Lunchtime_1.0.apk onto device 'emulator-5554'
[2011-05-01 02:20:20 - Lunchtime_1.0] Installing Lunchtime_1.0.apk...
[2011-05-01 02:20:39 - Lunchtime_1.0] Success!
[2011-05-01 02:20:39 - Lunchtime_1.0] Starting activity com.lunch.LunchtimeActivity on device emulator-5554
[2011-05-01 02:20:43 - Lunchtime_1.0] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.lunch/.LunchtimeActivity }
我從字面上絕對t使用Facebook本身爲Android提供的Facebook SDK,我無法使其工作。有任何想法嗎?
你在日誌貓看到什麼? – MByD 2011-04-30 14:59:35
'04-30 13:49:54.680:WARN/LauncherProvider(143):android.content.pm.PackageManager $ NameNotFoundException:ComponentInfo {com.google.android.apps.maps/com.google.android.maps.MapsActivity} ' – lollercoaster 2011-04-30 18:02:17
也'04-30 13:49:58.830:錯誤/ AndroidRuntime(160):錯誤:線程連接失敗' – lollercoaster 2011-04-30 18:02:42