android - Google + Sign In: Activity won't start -
i using com.actionbarsherlock.app.sherlockactivity in project. when try start activity need google+ sign in error occurs. getting error on actual device, not emulator. think doing wrong?
error
05-12 15:58:12.487: e/androidruntime(24310): fatal exception: main 05-12 15:58:12.487: e/androidruntime(24310): java.lang.runtimeexception: unable start activity componentinfo{com.google.android.gms/com.google.android.gms.plus.activity.accountsignupactivity}: java.lang.securityexception: must started via startactivityforresult 05-12 15:58:12.487: e/androidruntime(24310): @ android.app.activitythread.performlaunchactivity(activitythread.java:2180) 05-12 15:58:12.487: e/androidruntime(24310): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2230) 05-12 15:58:12.487: e/androidruntime(24310): @ android.app.activitythread.access$600(activitythread.java:141) 05-12 15:58:12.487: e/androidruntime(24310): @ android.app.activitythread$h.handlemessage(activitythread.java:1234) 05-12 15:58:12.487: e/androidruntime(24310): @ android.os.handler.dispatchmessage(handler.java:99) 05-12 15:58:12.487: e/androidruntime(24310): @ android.os.looper.loop(looper.java:137) 05-12 15:58:12.487: e/androidruntime(24310): @ android.app.activitythread.main(activitythread.java:5041) 05-12 15:58:12.487: e/androidruntime(24310): @ java.lang.reflect.method.invokenative(native method) 05-12 15:58:12.487: e/androidruntime(24310): @ java.lang.reflect.method.invoke(method.java:511) 05-12 15:58:12.487: e/androidruntime(24310): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793) 05-12 15:58:12.487: e/androidruntime(24310): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560) 05-12 15:58:12.487: e/androidruntime(24310): @ dalvik.system.nativestart.main(native method) 05-12 15:58:12.487: e/androidruntime(24310): caused by: java.lang.securityexception: must started via startactivityforresult 05-12 15:58:12.487: e/androidruntime(24310): @ com.google.android.gms.plus.activity.accountsignupactivity.oncreate(accountsignupactivity.java:119) 05-12 15:58:12.487: e/androidruntime(24310): @ android.app.activity.performcreate(activity.java:5104) 05-12 15:58:12.487: e/androidruntime(24310): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1080) 05-12 15:58:12.487: e/androidruntime(24310): @ android.app.activitythread.performlaunchactivity(activitythread.java:2144) 05-12 15:58:12.487: e/androidruntime(24310): ... 11 more
landingactivity.java
public class landingactivity extends sherlockactivity { @override public void oncreate(bundle savedinstancestate) { intent = new intent(getapplicationcontext(), signinactivity.class); this.startactivityforresult(i, 1); } }
signinactivity.java
import com.actionbarsherlock.app.sherlockactivity; import android.view.view; import android.app.progressdialog; import android.content.intent; import android.content.intentsender.sendintentexception; import android.os.bundle; import android.util.log; import android.widget.toast; //import com.google.android.gms.common.*; //import com.google.android.gms.common.googleplayservicesclient.*; import com.google.android.gms.common.connectionresult; import com.google.android.gms.common.googleplayservicesclient.connectioncallbacks; import com.google.android.gms.common.googleplayservicesclient.onconnectionfailedlistener; import com.google.android.gms.plus.plusclient; /** * example of signing in user google+, , how make call google+ api endpoint. */ public class signinactivity extends sherlockactivity implements view.onclicklistener, connectioncallbacks, onconnectionfailedlistener { private static final string tag = "exampleactivity"; private static final int request_code_resolve_err = 9000; private progressdialog mconnectionprogressdialog; private plusclient mplusclient; private connectionresult mconnectionresult; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.sign_in_activity); findviewbyid(r.id.sign_in_button_dude).setonclicklistener(this); mplusclient = new plusclient.builder(this, this, this).build(); //.setvisibleactivities("http://schemas.google.com/addactivity", "http://schemas.google.com/buyactivity") // progress bar displayed if connection failure not resolved. mconnectionprogressdialog = new progressdialog(this); mconnectionprogressdialog.setmessage("signing in..."); } @override protected void onstart() { super.onstart(); mplusclient.connect(); } @override protected void onstop() { super.onstop(); mplusclient.disconnect(); } public void onconnectionfailed(connectionresult result) { if (result.hasresolution()) { try { result.startresolutionforresult(this, request_code_resolve_err); } catch (sendintentexception e) { mplusclient.connect(); } } // save result , resolve connection failure upon user click. mconnectionresult = result; } @override protected void onactivityresult(int requestcode, int responsecode, intent intent) { if (requestcode == request_code_resolve_err && responsecode == result_ok) { mconnectionresult = null; mplusclient.connect(); } } public void onconnected() { string accountname = mplusclient.getaccountname(); //mconnectionprogressdialog.dismiss(); //https://developers.google.com/+/mobile/android/sign-in toast.maketext(this, accountname + " connected.", toast.length_long).show(); //toast.maketext(this, "user connected!", toast.length_long).show(); } public void ondisconnected() { log.d(tag, "disconnected"); } public void onclick(view view) { if (view.getid() == r.id.sign_in_button_dude && !mplusclient.isconnected()) { if (mconnectionresult == null) { mconnectionprogressdialog.show(); } else { try { mconnectionresult.startresolutionforresult(this, request_code_resolve_err); } catch (sendintentexception e) { // try connecting again. mconnectionresult = null; mplusclient.connect(); } } } } }
i have tried using "setscopes(scopes.plus_login)" ran same issue.
import com.google.android.gms.common.scopes; // in oncreate() mplusclient = new plusclient.builder(this, this, this).setscopes(scopes.plus_login).build();
i tried starting keytool .... androiddebugkey needed? https://developers.google.com/+/mobile/android/getting-started
c:\repos>c:\java\jdk1.6.0_34\bin\keytool.exe -exportcert -alias androiddebugkey -keystore agoyal-release-key.keystore -list -v enter keystore password: keytool error: java.lang.exception: alias <androiddebugkey> not exist java.lang.exception: alias <androiddebugkey> not exist @ sun.security.tools.keytool.doprintentry(keytool.java:1339) @ sun.security.tools.keytool.docommands(keytool.java:869) @ sun.security.tools.keytool.run(keytool.java:172) @ sun.security.tools.keytool.main(keytool.java:166)
for keytool command, if use own release key, alias should 1 key used, not "androiddebugkey".
Comments
Post a Comment