0

我编写了以下代码片段以在使用linkedIn 登录后获取用户详细信息。但是点击按钮后,什么也没有发生。我将如何被重定向到linkedin 登录页面?请帮忙

公共类 MainActivity 扩展 Activity {

SocialAuthAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final SocialAuthAdapter adapter = new SocialAuthAdapter(new ResponseListener());


    Button linkedin_button = (Button)findViewById(R.id.button1);

    //adapter.enable(linkedin_button);
    linkedin_button.setOnClickListener(new OnClickListener() 
    {
       public void onClick(View v) 
       {
           adapter.authorize(MainActivity.this, Provider.LINKEDIN);
       }
   });

  }

private final class ResponseListener implements DialogListener 
{
   public void onComplete(Bundle values) {

     //SocialAuthAdapter adapter = null;
    adapter.getUserProfileAsync(new ProfileDataListener());                   
   }
}

// 认证后接收配置文件响应 private final class ProfileDataListener implements SocialAuthListener {

public void onExecute(Profile t) {

   Log.d("Custom-UI", "Receiving Data");
   Profile profileMap = t;
   Log.d("Custom-UI",  "Validate ID         = " + profileMap.getValidatedId());
   Log.d("Custom-UI",  "First Name          = " + profileMap.getFirstName());
   Log.d("Custom-UI",  "Last Name           = " + profileMap.getLastName());
   Log.d("Custom-UI",  "Email               = " + profileMap.getEmail());
   Log.d("Custom-UI",  "Country                  = " + profileMap.getCountry());
   Log.d("Custom-UI",  "Language                 = " + profileMap.getLanguage());
   Log.d("Custom-UI",  "Location                 = " + profileMap.getLocation());
   Log.d("Custom-UI",  "Profile Image URL  = " + profileMap.getProfileImageURL());

}    

}

http://www.3pillarglobal.com/blog/part-2-using-socialauth-integrate-linkedin-api-android

4

1 回答 1

0

将此添加到您的活动中

// To receive the response after authentication
        private final class ResponseListener implements DialogListener {
        @Override
        public void onComplete(Bundle values) {

            Log.d("Custom-UI", "Successful");

            // Get the provider
            providerName = values.getString(SocialAuthAdapter.PROVIDER);
            Log.d("Custom-UI", "providername = " + providerName);

            Toast.makeText(MainActivity.this, providerName + " connected", Toast.LENGTH_SHORT).show();

            mDialog = new ProgressDialog(MainActivity.this);
            mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            mDialog.setMessage("Loading.......");

            adapter.getUserProfileAsync(new ProfileDataListener());

            Toast.makeText(MainActivity.this, "Display Details", Toast.LENGTH_LONG).show();
        }

        @Override
        public void onError(SocialAuthError error) {
            Log.d("Custom-UI", "Error");
            error.printStackTrace();
        }

        @Override
        public void onCancel() {
            Log.d("Custom-UI", "Cancelled");
        }

        @Override
        public void onBack() {
            Log.d("Custom-UI", "Dialog Closed by pressing Back Key");

        }
    }
于 2014-04-01T08:15:18.997 回答