Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android SocialAuth-Can';我无法通过Facebook获得位置信息_Android_Facebook_Twitter_Socialauth - Fatal编程技术网

Android SocialAuth-Can';我无法通过Facebook获得位置信息

Android SocialAuth-Can';我无法通过Facebook获得位置信息,android,facebook,twitter,socialauth,Android,Facebook,Twitter,Socialauth,我目前正试图通过用户现有的社交网络数据在Android应用程序中生成用户配置文件。我正在使用Socialuth库登录并从应用程序中提取数据,并在片段中填充一些文本字段 我目前正在使用Facebook和Twitter,但我无法通过Facebook接收个人资料的“位置”。Twitter能够成功获取位置信息,但Facebook在发送get请求时只会显示“Null” 让事情复杂化的是,当我访问Facebook帐户时,我正在使用SocialAuth提供的示例应用程序进行测试,它能够毫无问题地获取位置,但尽

我目前正试图通过用户现有的社交网络数据在Android应用程序中生成用户配置文件。我正在使用Socialuth库登录并从应用程序中提取数据,并在片段中填充一些文本字段

我目前正在使用Facebook和Twitter,但我无法通过Facebook接收个人资料的“位置”。Twitter能够成功获取位置信息,但Facebook在发送get请求时只会显示“Null”

让事情复杂化的是,当我访问Facebook帐户时,我正在使用SocialAuth提供的示例应用程序进行测试,它能够毫无问题地获取位置,但尽管我的代码相同,Twitter运行的代码相同,但它在我的应用程序中无法工作

有人能解释一下为什么我无法在我的应用程序中通过Facebook检索位置吗?我将在下面提供我的相关课程:

LoginActivity.java

import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

import org.brickred.socialauth.android.DialogListener;
import org.brickred.socialauth.android.SocialAuthAdapter;
import org.brickred.socialauth.android.SocialAuthError;
import org.brickred.socialauth.android.SocialAuthListener;
import org.brickred.socialauth.Profile;

public class LoginActivity extends ActionBarActivity {

    private static SocialAuthAdapter adapter;
    private Button facebook_button;
    private Button twitter_button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        adapter = new SocialAuthAdapter(new ResponseListener());

        facebook_button = (Button)findViewById(R.id.fbSignUp);
        twitter_button = (Button)findViewById(R.id.twitSignUp);

        facebook_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                adapter.authorize(LoginActivity.this, SocialAuthAdapter.Provider.FACEBOOK);
            }
        });

        twitter_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                adapter.authorize(LoginActivity.this, SocialAuthAdapter.Provider.TWITTER);
            }
        });
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_login, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    private class ResponseListener implements DialogListener {
        @Override
        public void onComplete(Bundle bundle) {
            adapter.getUserProfileAsync(new ProfileDataListener());
        }

        @Override
        public void onError(SocialAuthError socialAuthError) {

        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onBack() {

        }
    }

    private class ProfileDataListener implements SocialAuthListener<Profile> {
        @Override
        public void onExecute(String provider, Profile t) {

            Profile profileMap = t;

            Intent intent = new Intent(LoginActivity.this, HubPage.class);
            intent.putExtra("provider", provider);
            intent.putExtra("profile", profileMap);
            startActivity(intent);

        }

        @Override
        public void onError(SocialAuthError socialAuthError) {

        }
    }
}
任何帮助都将不胜感激,因为我似乎无法找到任何解决方案,尽管数小时的努力

import android.os.Bundle;
import android.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import org.brickred.socialauth.Profile;
import org.brickred.socialauth.android.SocialAuthAdapter;

public class ProfileFragment extends Fragment {

    SocialAuthAdapter adapter;
    Profile profileMap;

    // Android Components
    TextView name;
    TextView location;
    ImageView image;

    // Variables
    String provider_name;
    //ImageLoader imageLoader;


    public ProfileFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View rootView = inflater.inflate(R.layout.fragment_hub_page, container, false);

        profileMap = (Profile) getActivity().getIntent().getSerializableExtra("profile");
        Log.d("Profile", "Validate ID = " + profileMap.getValidatedId());
        Log.d("Profile", "First Name  = " + profileMap.getFirstName());
        Log.d("Profile", "Last Name   = " + profileMap.getLastName());
        Log.d("Profile", "Location    = " + profileMap.getLocation());
        Log.d("Profile", "Profile Image URL  = " + profileMap.getProfileImageURL());

        provider_name = getActivity().getIntent().getStringExtra("provider");

        // Set title
        name = (TextView) rootView.findViewById(R.id.profileName);
        location = (TextView) rootView.findViewById(R.id.profileLocation);
        image = (ImageView) rootView.findViewById(R.id.profilePic);

        //imageLoader = new ImageLoader(ProfileActivity.this);

        //imageLoader.DisplayImage(profileMap.getProfileImageURL(), image);

        // Name
        if (profileMap.getFullName() == null)
            name.setText(profileMap.getFirstName() + profileMap.getLastName());
        else
            name.setText(profileMap.getFullName());

        // Location
        location.setText(profileMap.getLocation());

        return rootView;
    }

}