0

私は、linkedIn でログインした後にユーザーの詳細を取得するために、次のコード スニペットを作成しました。しかし、ボタンをクリックしても何も起こりません。リンクインのログイン ページにリダイレクトするにはどうすればよいですか? 助けてください

public class MainActivity extends 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 implement 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 に答える