我正在尝试使用 Google Plus 登录我的应用程序。我第一次尝试时,它征求我的同意,我接受了。在我转到我的 Google Plus 个人资料并删除我的应用程序之后。现在我尝试重新登录,但它没有征求我的任何许可。如果我在 GoogleApiClient 配置中添加新范围,它会再次询问我..
如何永久清除我的手机申请?
我试试这样;
if(mGoogleApiClient.isConnected()){
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
mGoogleApiClient.disconnect();
mGoogleApiClient.connect();
Log.d("deneme", "Google Profile shutdown");
}
else
Log.d("deneme", "Google already shutdown");
还有一个问题,我试图像这样获取用户的个人资料信息,但出现错误。
@Override
public void onConnected(Bundle connectionHint) {
mSignInClicked = false;
Log.d("deneme", "onConnected");
if(mGoogleApiClient.isConnected()){
Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
if(currentPerson.isPlusUser())
Log.d("deneme", currentPerson.getDisplayName());
}
}
public class NotRegistered extends SherlockFragment implements View.OnClickListener, ConnectionCallbacks, OnConnectionFailedListener {
@Override
public void onStart() {
super.onStart();
mGoogleApiClient.connect();
Log.d("deneme","onStart");
}
@Override
public void onStop() {
super.onStop();
if(mGoogleApiClient.isConnected()){
mGoogleApiClient.disconnect();
Log.d("deneme","onStop");
}
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
Log.d("deneme", "onActivityCreated");
super.onActivityCreated(savedInstanceState);
ViewFlipper vf = (ViewFlipper) getActivity().findViewById(R.id.viewFlipper1);
vf.setFlipInterval(11000);
vf.startFlipping();
Button b_gmail = (Button) getActivity().findViewById(R.id.BTN_sign_gmail);
Button m_loginButton = (Button) getActivity().findViewById(R.id.BTN_register);
Button m_registerButton = (Button) getActivity().findViewById(R.id.BTN_login);
getActivity().findViewById(R.id.sign_in_button).setOnClickListener(this);
mSignInButton = (SignInButton) getActivity().findViewById(R.id.sign_in_button);
mSignInButton.setOnClickListener(this);
b_facebook = (LoginButton) getActivity().findViewById(R.id.BTN_sign_facebook);
b_facebook.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
b_facebook.setReadPermissions(Arrays.asList("user_likes", "email", "user_status", "user_about_me"));
b_facebook.setBackgroundResource(R.drawable.login_facebook_button);
b_facebook.setFragment(this);
m_loginButton.setOnClickListener(this);
m_registerButton.setOnClickListener(this);
b_gmail.setOnClickListener(this);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Log.d("deneme", "Not Register onCreateView");
View view;
view = inflater.inflate(R.layout.notregistered_fragment, container, false);
uiHelper = new UiLifecycleHelper(getActivity(), callback);
uiHelper.onCreate(savedInstanceState);
mGoogleApiClient = new GoogleApiClient.Builder(getActivity().getApplicationContext())
.addApi(Plus.API, null)
.addScope(Plus.SCOPE_PLUS_LOGIN)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
return view;
}
private void onSessionStateChange(Session session, SessionState sessionState, Exception exception){
if(sessionState.isOpened()){
Log.d("deneme", "Oturum Açık");
Log.d("deneme", session.getAccessToken());
//boolean returnVal = new UserRecord().execute(val);
makeMeRequest(session);
Intent i = new Intent(getActivity(), Pager.class);
startActivity(i);
getActivity().finish();
} else {
Log.d("deneme", "Oturum Kapalı");
}
}
private void makeMeRequest(final Session session) {
Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
if (session == Session.getActiveSession()) {
if (user != null) {
new NewUserAsync().execute("facebook", user.getUsername(), user.getFirstName(),
user.getLastName(), user.getProperty("email").toString(), user.getId(),
user.getBirthday().toString());
}
}
if (response.getError() != null) {
Log.d("deneme",response.getError().toString());
}
}
});
request.executeAsync();
}
private Session.StatusCallback callback = new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
Log.d(TAG, "callback");
onSessionStateChange(session, state, exception);
}
};
@Override
public void onClick(View v) {
Register register = new Register();
switch (v.getId()) {
case R.id.BTN_sign_gmail:
if(mGoogleApiClient.isConnected()){
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
mGoogleApiClient.disconnect();
mGoogleApiClient.connect();
if(mGoogleApiClient.isConnected())
Log.d("deneme", "Google profili sonlandırılamadı");
else
Log.d("deneme", "Google profili sonlandırıldı");
} else
Log.d("deneme", "Oturum zaten kapalı");
break;
case R.id.BTN_register:
getActivity().getSupportFragmentManager().beginTransaction().addToBackStack(null).replace(R.id.test, register, "register").commit();
break;
case R.id.BTN_login:
Intent i = new Intent(getActivity().getApplicationContext(), Pager.class);
startActivity(i);
//getActivity().getSupportFragmentManager().beginTransaction().addToBackStack(null).replace(R.id.test, register, "register").commit();
break;
case R.id.sign_in_button:
if(!mGoogleApiClient.isConnecting()){
mSignInClicked = true;
resolveSignInError();
Toast.makeText(getActivity(), "küçük buttona tıklandı", Toast.LENGTH_LONG).show();
}
break;
default:
break;
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
uiHelper.onActivityResult(requestCode, resultCode, data);
Log.d("deneme", "onActivityResult");
if(requestCode == RC_SIGN_IN){
if(resultCode != getActivity().RESULT_OK){
mSignInClicked = false;
}
}
mIntentInProgress = false;
if(!mGoogleApiClient.isConnecting()){
mGoogleApiClient.connect();
}
}
@Override
public void onDestroy() {
super.onDestroy();
uiHelper.onDestroy();
Log.d("deneme", "onDestroy");
}
@Override
public void onPause() {
super.onPause();
uiHelper.onPause();
Log.d("deneme", "onPause");
}
@Override
public void onResume() {
super.onResume();
uiHelper.onResume();
Log.d("deneme", "onResume");
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
uiHelper.onSaveInstanceState(outState);
Log.d("deneme", "onSaveInstanceState");
}
public static final String TAG = "deneme";
private LoginButton b_facebook;
private UiLifecycleHelper uiHelper;
// Google Plus Connect Starting
@Override
public void onConnected(Bundle connectionHint) {
mSignInClicked = false;
Toast.makeText(getActivity(), "Kullanıcı bağlı", Toast.LENGTH_LONG).show();
Log.d("deneme", "onConnected");
}
@Override
public void onConnectionSuspended(int cause) {
mGoogleApiClient.connect();
}
@Override
public void onConnectionFailed(ConnectionResult result) {
if(!mIntentInProgress){
mConnectionResult = result;
if(mSignInClicked){
resolveSignInError();
}
}
}
private void resolveSignInError() {
Log.d("deneme", "Buraya bir geldi : resolveSignInError");
if (mConnectionResult.hasResolution()) {
try {
mIntentInProgress = true;
mConnectionResult.startResolutionForResult(getActivity(), RC_SIGN_IN);
Log.d("deneme", "resolveSignInError try içerisinde");
} catch (SendIntentException e) {
mIntentInProgress = false;
mGoogleApiClient.connect();
Log.d("deneme", "resolveSignInError catch içerisinde");
}
}
}
SignInButton mSignInButton;
GoogleApiClient mGoogleApiClient;
ConnectionResult mConnectionResult;
boolean mIntentInProgress = false;
boolean mSignInClicked;
int RC_SIGN_IN = 0;
}
第 241 行:public void onConnectionSuspended(int cause) 函数。
首先,如何删除我的测试用户以及如何获取他们的个人资料信息..
谢谢你的帮助..