Android Linkedin init没有回调触发器

时间:2015-03-27 11:42:15

标签: java android linkedin

我正在使用新的Linkedin API(https://developer.linkedin.com/docs) 我已完成导入,项目运行时没有崩溃。

这是我的MainActivity实现(https://developer.linkedin.com/docs/android-sdk-auth):

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    // Store a reference to the current activity
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final Activity thisActivity = this;

    // Build the list of member required permissions
    List<String> scope = new ArrayList<String>();
    scope.add("r_basicprofile");
    scope.add("w_share");

    LISessionManager.getInstance(getApplicationContext()).init(thisActivity, buildScope(), new AuthListener() {

        @Override
        public void onAuthSuccess() {
            // Authentication was successful.  You can now do
            // other calls with the SDK.
            Toast.makeText(getApplicationContext(), "onAuthSuccess", Toast.LENGTH_SHORT).show();
            Log.d("nitai", "success");
        }

        @Override
        public void onAuthError(LIAuthError error) {
            // Handle authentication errors
            Toast.makeText(getApplicationContext(), "onAuthError", Toast.LENGTH_SHORT).show();
            Log.d("nitai", "fail");

        }


    }, true);
}

// Build the list of member permissions our LinkedIn session requires
private static Scope buildScope() {
    return Scope.build(Scope.R_BASICPROFILE, Scope.W_SHARE);
}
@Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        LISessionManager.getInstance(getApplicationContext()).onActivityResult(this, requestCode, resultCode, data);
    }

    }

问题是没有触发任何回调(OAuthSuccess / OAuthError)。

1 个答案:

答案 0 :(得分:4)

将此行添加到您的“适用于您的活动”

@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { LISessionManager.getInstance(getApplicationContext()).onActivityResult(this, requestCode, resultCode, data); }