0
일부 텍스트에서 SSO 및 onClickListener를 사용하여 내 상태를 업데이트하려고하는데 post_badge_text를 클릭하면 인터페이스가 처리기 오류로 구현되지 않습니다.SSO가있는 Android Facebook - 인터페이스가 구현되지 않았습니다. 오류
다음은 클래스의 소스입니다. 여기
import com.facebook.android.BaseDialogListener;
import com.facebook.android.Facebook;
import com.facebook.android.R;
import com.facebook.android.Utility;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.facebook.android.Facebook.*;
public class SocialSharing extends Activity{
private static final String APP_ID = "286529654765268";
//private static final String[] PERMISSIONS = new String[] {"publish_stream"};
private static final String TOKEN = "access_token";
private static final String EXPIRES = "expires_in";
private static final String KEY = "facebook-credentials";
private Facebook facebook = new Facebook(APP_ID);
private EditText edittext;
private ImageView badge;
private TextView post_badge_text;
private TextView update_status_text;
private TextView post_achievement_text;
private TextView tweet_badge_text;
private TextView invite_friends_text;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.socialsharing);
//Make references to all our views
edittext = (EditText) findViewById(R.id.edittext);
badge = (ImageView) findViewById(R.id.badge);
post_badge_text = (TextView) findViewById(R.id.post_badge_text);
update_status_text = (TextView) findViewById(R.id.update_status_text);
post_achievement_text = (TextView) findViewById(R.id.post_achievement_text);
tweet_badge_text = (TextView) findViewById(R.id.tweet_badge_text);
invite_friends_text = (TextView) findViewById(R.id.invite_friends_text);
if(restore(facebook, getApplicationContext())){
//authorize the user.
facebook.authorize(this, new DialogListener() {
@Override
public void onComplete(Bundle values) {
Toast.makeText(getApplicationContext(), "Successfully Logged In to facebook!", Toast.LENGTH_LONG).show();
}
@Override
public void onCancel() {}
@Override
public void onFacebookError(com.facebook.android.FacebookError e) {
e.printStackTrace();
if(facebook.isSessionValid()){
Toast.makeText(getApplicationContext(), "Successfully Logged in to Facebook!", Toast.LENGTH_LONG).show();
}
else{
Log.e("FACEBOOK FAIL", "Facebook has epicly failed with an error in onCreate in Social Sharing or you are logged in already");
}
}
@Override
public void onError(com.facebook.android.DialogError e) {
// TODO Auto-generated method stub
}
});
} else { save(facebook, getApplicationContext()); }
/*
* callback for the feed dialog which updates the profile status
*/
class UpdateStatusListener extends BaseDialogListener {
public void onComplete(Bundle values) {
final String postId = values.getString("post_id");
if (postId != null) {
new UpdateStatusResultDialog(SocialSharing.this, "Update Status executed", values)
.show();
} else {
Toast toast = Toast.makeText(getApplicationContext(), "No wall post made",
Toast.LENGTH_SHORT);
toast.show();
}
}
}
//check for clicks
post_badge_text.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle params = new Bundle();
params.putString("caption", getString(R.string.app_name));
params.putString("description", getString(R.string.app_desc));
params.putString("picture", Utility.HACK_ICON_URL);
params.putString("name", getString(R.string.app_action));
Utility.mFacebook.dialog(SocialSharing.this, "feed", params, new UpdateStatusListener());
String access_token = Utility.mFacebook.getAccessToken();
Log.e("accessToken", "access Token is " + access_token);
System.out.println(access_token);
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
facebook.authorizeCallback(requestCode, resultCode, data);
}
/*
* Save the access token and expiry date so you don't have to fetch it each
* time
*/
public static boolean save(Facebook session, Context context) {
Editor editor = context.getSharedPreferences(KEY, Context.MODE_PRIVATE).edit();
editor.putString(TOKEN, session.getAccessToken());
editor.putLong(EXPIRES, session.getAccessExpires());
return editor.commit();
}
/*
* Restore the access token and the expiry date from the shared preferences.
*/
public static boolean restore(Facebook session, Context context) {
SharedPreferences savedSession = context.getSharedPreferences(KEY, Context.MODE_PRIVATE);
session.setAccessToken(savedSession.getString(TOKEN, null));
session.setAccessExpires(savedSession.getLong(EXPIRES, 0));
return session.isSessionValid();
}
}
내가 점점 오전 오류입니다 :
05-09 12:31:22.300: E/Handler(12860): Failed to handle callback; interface not implemented, callback:[email protected]
05-09 12:31:22.300: E/Handler(12860): java.lang.NullPointerException
05-09 12:31:22.300: E/Handler(12860): at org.jujitsu.app.com.SocialSharing$2.onClick(SocialSharing.java:114)
05-09 12:31:22.300: E/Handler(12860): at android.view.View.performClick(View.java:3538)
05-09 12:31:22.300: E/Handler(12860): at android.view.View$PerformClick.run(View.java:14330)
05-09 12:31:22.300: E/Handler(12860): at android.os.Handler.handleCallback(Handler.java:607)
05-09 12:31:22.300: E/Handler(12860): at android.os.Handler.dispatchMessage(Handler.java:92)
05-09 12:31:22.300: E/Handler(12860): at android.os.Looper.loop(Looper.java:154)
05-09 12:31:22.300: E/Handler(12860): at android.app.ActivityThread.main(ActivityThread.java:4974)
05-09 12:31:22.300: E/Handler(12860): at java.lang.reflect.Method.invokeNative(Native Method)
05-09 12:31:22.300: E/Handler(12860): at java.lang.reflect.Method.invoke(Method.java:511)
05-09 12:31:22.300: E/Handler(12860): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-09 12:31:22.300: E/Handler(12860): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-09 12:31:22.300: E/Handler(12860): at dalvik.system.NativeStart.main(Native Method)
난 정말이 오류와 함께 붙어 있어요 ... 어떤 도움도 좋은 것입니다. 감사!
댓글을 작성하는 데 다소 늦었지만 레이아웃 socialsharing.xml을 게시 할 수 있습니까? TextView에 'android : clickable = "true"'속성이 설정되어 있어야한다고 생각합니다. –