This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using HuaweiMobileServices.Id; | |
using HuaweiMobileServices.Utils; | |
using UnityEngine; | |
using UnityEngine.UI; | |
using HmsPlugin; | |
using UnityEngine.SceneManagement; | |
public class AccountSignIn : MonoBehaviour | |
{ | |
private const string NOT_LOGGED_IN = "No user logged in"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
google() | |
jcenter() | |
maven { url 'http://developer.huawei.com/repo/' } | |
} | |
dependencies { | |
classpath 'com.android.tools.build:gradle:3.6.3' | |
classpath 'com.huawei.agconnect:agcp:1.3.1.300' | |
// NOTE: Do not place your application dependencies here; they belong |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.team3.animalsintroduction.common; | |
import android.app.Activity; | |
import android.app.AlertDialog; | |
import android.content.ActivityNotFoundException; | |
import android.content.DialogInterface; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.util.Log; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void insertPhoto(Photo photo) { | |
state = false; | |
if (mCloudDBZone == null) { | |
Log.w(Constant.DB_ZONE_WRAPPER, "INSERT Photo : CloudDBZone is null, try re-open it"); | |
return; | |
} | |
CloudDBZoneTask<Integer> upsertTask = mCloudDBZone.executeUpsert(photo); | |
if (mUiCallBack == null) { | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void getAllPhotos(Context mContext) { | |
if (mCloudDBZone == null) { | |
Log.w(Constant.DB_ZONE_WRAPPER, "GET USER DETAIL : CloudDBZone is null, try re-open it"); | |
return; | |
} | |
SharedPreferences pref = mContext.getSharedPreferences("MyPref", mContext.MODE_PRIVATE); | |
String token = pref.getString("token",null); | |
CloudDBZoneTask<CloudDBZoneSnapshot<Photo>> queryTask = mCloudDBZone.executeQuery( | |
CloudDBZoneQuery.where(Photo.class).orderByDesc("id").equalTo("token",token ).limit(1), | |
CloudDBZoneQuery.CloudDBZoneQueryPolicy.POLICY_QUERY_FROM_CLOUD_ONLY); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onAddOrQueryPhoto(List<Photo> photoList) { | |
photo = photoList.get(0); | |
Intent intent = new Intent(AnimalActivity.this, PhotoActivity.class); | |
//creates the temporary file and gets the path | |
Bitmap bitmap = BitmapFactory.decodeByteArray(photo.getPhoto(), 0, photo.getPhoto().length); | |
String filePath= tempFileImage(this,bitmap,"name"); | |
//passes the file path string with the intent | |
intent.putExtra("path", filePath); | |
loadinPanel.setVisibility(View.GONE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |
super.onActivityResult(requestCode, resultCode, data); | |
if (requestCode == 1001) { | |
Task<AuthHuaweiId> authHuaweiIdTask = HuaweiIdAuthManager.parseAuthResultFromIntent(data); | |
if (authHuaweiIdTask.isSuccessful()) { | |
AuthHuaweiId huaweiAccount = authHuaweiIdTask.getResult(); | |
Log.i(TAG, "signIn success Access Token = " + huaweiAccount.getAccessToken()); | |
Log.i(TAG, "signIn success User Name = " + huaweiAccount.getDisplayName()); | |
} | |
else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void transmitTokenIntoAppGalleryConnect(String accessToken) { | |
AGConnectAuthCredential credential = HwIdAuthProvider.credentialWithToken(accessToken); | |
AGConnectAuth.getInstance().signIn(credential).addOnSuccessListener(new OnSuccessListener<SignInResult>() { | |
@Override | |
public void onSuccess(SignInResult signInResult) { | |
startActivity(new Intent(MainActivity.this, HomePageActivity.class)); | |
finish(); | |
} | |
}).addOnFailureListener(new OnFailureListener() { | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AGConnectAuth.getInstance().signInAnonymously().addOnSuccessListener(new OnSuccessListener<SignInResult>() { | |
@Override | |
public void onSuccess(SignInResult signInResult) { | |
startActivity(new Intent(MainActivity.this, HomePageActivity.class)); | |
finish(); | |
} | |
}).addOnFailureListener(new OnFailureListener() { | |
@Override | |
public void onFailure(Exception e) { | |
Log.d(TAG, "Error " + e); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize the HUAWEI Ads SDK. | |
HwAds.init(this); | |
// Call new BannerView(Context context) to create a BannerView class. | |
BannerView topBannerView = new BannerView(this); | |
topBannerView.setAdId(Constant.AD_ID); | |
topBannerView.setBannerAdSize(BannerAdSize.BANNER_SIZE_360_57); | |
topBannerView.loadAd(adParam); | |
ConstraintLayout rootView = findViewById(R.id.mainActivity); | |
rootView.addView(topBannerView); |
OlderNewer