当前位置: 首页 > news >正文

定西市网站建设咨询win7系统优化工具

定西市网站建设咨询,win7系统优化工具,南方人才网,怎样做国外网站推广一、接入的准备工作 官方文档链接地址:开始使用一键登录和注册 按照步骤进行接入即可 二、项目参考(Unity项目) 注意:代码版本如果不适用新的Google API 请自行参考最新版本接口 SDKGoogleSignInActivity 主要用于登录的代码。Un…

一、接入的准备工作

官方文档链接地址:开始使用一键登录和注册

按照步骤进行接入即可

二、项目参考(Unity项目)

注意:代码版本如果不适用新的Google API 请自行参考最新版本接口

SDKGoogleSignInActivity 主要用于登录的代码。UnityPlayer.UnitySendMessage的参数按照自己项目填写,com.xxxxx.my也是填写自己项目的路径。

package com.xxxxx.my;import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.TextView;import com.zhijingweilai.domino.R;
import com.google.android.gms.auth.api.signin.GoogleSignIn;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.common.api.ApiException;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.unity3d.player.UnityPlayer;/*** Activity to demonstrate basic retrieval of the Google user's ID, email address, and basic* profile.*/
public class SDKGoogleSignInActivity extends AppCompatActivity {private static final String TAG = "SignInActivity";private static final int RC_SIGN_IN = 1234; // Can be any integer unique to the Activity.private GoogleSignInClient mGoogleSignInClient;private TextView mStatusTextView;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);// [START configure_signin]// Configure sign-in to request the user's ID, email address, and basic// profile. ID and basic profile are included in DEFAULT_SIGN_IN.String clientId = getString(R.string.server_client_id);GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().requestIdToken(clientId).build();// [END configure_signin]// [START build_client]// Build a GoogleSignInClient with the options specified by gso.mGoogleSignInClient = GoogleSignIn.getClient(this, gso);// [END build_client]}public void SendLogin() {GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);if (account != null && !account.isExpired()) {updateUI(account, "");}elsesignIn();}// [START onActivityResult]@Overridepublic void onActivityResult(int requestCode, int resultCode, Intent data) {super.onActivityResult(requestCode, resultCode, data);// Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);if (requestCode == RC_SIGN_IN) {// The Task returned from this call is always completed, no need to attach// a listener.Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);handleSignInResult(task);}}// [END onActivityResult]// [START handleSignInResult]private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {try {GoogleSignInAccount account = completedTask.getResult(ApiException.class);// Signed in successfully, show authenticated UI.updateUI(account, "");} catch (ApiException e) {// The ApiException status code indicates the detailed failure reason.// Please refer to the GoogleSignInStatusCodes class reference for more information.Log.w(TAG, "signInResult:failed code=" + e.getStatusCode());updateUI(null, e.toString());}}// [END handleSignInResult]// [START signIn]public void signIn() {Intent signInIntent = mGoogleSignInClient.getSignInIntent();startActivityForResult(signInIntent, RC_SIGN_IN);}// [END signIn]// [START signOut]public void signOut() {mGoogleSignInClient.signOut().addOnCompleteListener(this, new OnCompleteListener<Void>() {@Overridepublic void onComplete(@NonNull Task<Void> task) {String str = new JsonToString().AddJSONObject("result", 0).AddJSONObject("msg", "signout").GetString();Log.i("Google", "Google SignOut str=" + str);UnityPlayer.UnitySendMessage("SDK_callback", "OnGGSignOutResult", str);finish();}});}// [END signOut]// [START revokeAccess]public void revokeAccess() {mGoogleSignInClient.revokeAccess().addOnCompleteListener(this, new OnCompleteListener<Void>() {@Overridepublic void onComplete(@NonNull Task<Void> task) {String str = new JsonToString().AddJSONObject("result", 0).AddJSONObject("msg", "revokeAccess").GetString();Log.i("Google", "Google RevokeAccess str=" + str);UnityPlayer.UnitySendMessage("SDK_callback", "OnGGRevokeAccessResult", str);finish();}});}// [END revokeAccess]private void updateUI(@Nullable GoogleSignInAccount acct, String err) {if (acct != null){String idToken = acct.getIdToken();String personName = acct.getDisplayName();String personGivenName = acct.getGivenName();String personFamilyName = acct.getFamilyName();String personEmail = acct.getEmail();String personId = acct.getId();Uri personPhoto = acct.getPhotoUrl();Log.i("Google", "Google SignIn URI=" + personPhoto.toString());Log.i("Google", "Google SignIn URI=" + personPhoto.getPath());Log.i("Google", "Google SignIn URI=" + personPhoto.getQuery());String str = new JsonToString().AddJSONObject("result", 0).AddJSONObject("msg", "signin").AddJSONObject("refresh_token", idToken).AddJSONObject("personName", personName).AddJSONObject("personGivenName", personGivenName).AddJSONObject("personFamilyName", personFamilyName).AddJSONObject("personEmail", personEmail).AddJSONObject("loginId", personId).AddJSONObject("iconUrl", personPhoto.toString()).GetString();Log.i("Google", "Google SignIn str=" + str);UnityPlayer.UnitySendMessage("SDK_callback", "OnGGSignInResult", str);acct = null;}else{String str = new JsonToString().AddJSONObject("result", 1).AddJSONObject("msg", "signin").AddJSONObject("err", err).GetString();Log.i("Google", "Google SignIn str=" + str);UnityPlayer.UnitySendMessage("SDK_callback", "OnGGSignInResult", str);}finish();}}

 JsonToString 用于处理数据,将json数据转成string方便传输

package com.xxxxx.my;import org.json.JSONObject;public class JsonToString {private JSONObject jsonObj;public JsonToString(){jsonObj = new JSONObject();};public JsonToString AddJSONObject(String key, Object val) {try {jsonObj.put(key, val);}catch(Exception e) {}return this;}public String GetString(){String str = jsonObj.toString();return str;}
}

http://www.yayakq.cn/news/240005/

相关文章:

  • 免费的ppt模板网站有哪些电子商务网站建设与维护03
  • 园区门户网站建设方案wordpress 简书模板
  • wordpress 首页模板在哪里可以免费自学seo课程
  • 世界杯网站源码下载百度云加速 网站关键词
  • 电脑网站微信支付怎么做的网站建设最基础是什么
  • 做小说网站做国外域名还是国内的好处网站开发和网站维护有区别吗
  • 单位网站建设管理情况网络营销与直播电商专业就业方向
  • 网络网站建设属于什么费用昌大建设集团大老板
  • 宿州企业网站推广网页设计考试
  • 优良的定制网站建设公司微信分销系统软件
  • 发卡网站建设7azseo搜索优化
  • 手机免费网站制作网站用户体验模型
  • 做网站编辑工作好不好做分类信息网站
  • 阿里巴巴的网站是自己做的吗电子商务网站建设软件
  • 利川做网站和女的做那个视频网站
  • php网站开发专业介绍画江湖网站开发文档
  • 青岛全网营销推广搜索引擎优化简历
  • 17网站一起做网店app百度收录网站要多
  • 网站需求文档阿里云 oos wordpress
  • 苏州高新区建设局网站网页布局设计主要有什么类型
  • 做超市dm的网站推广策略图片
  • 租车网站建设方案网站源码提取
  • 免费看电视剧网站2020设计企业
  • 特效网站模板葫芦岛长城建设公司网站
  • 沈阳电子商务网站建设sem推广和seo的区别
  • 网站建设模板平台wordpress固定链接打不开
  • 网站建设与管理 第2版网站页面制作软件
  • 灵山招聘网灵山英才网做灵山专业的招聘网站宁波招聘网站开发
  • a5站长网网站交易网络营销渠道的类型
  • 建设企业网站公司价格安阳 网站建设