com.google.android.gms.auth.api.signin.GoogleSignIn Java Examples

The following examples show how to use com.google.android.gms.auth.api.signin.GoogleSignIn. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AndroidGoogleDrive.java    From QtAndroidTools with MIT License 9 votes vote down vote up
public boolean authenticate(String AppName, String ScopeName)
{
    final GoogleSignInAccount SignInAccount = GoogleSignIn.getLastSignedInAccount(mActivityInstance);

    if(SignInAccount != null)
    {
        GoogleAccountCredential AccountCredential;
        Drive.Builder DriveBuilder;

        AccountCredential = GoogleAccountCredential.usingOAuth2(mActivityInstance, Collections.singleton(ScopeName));
        AccountCredential.setSelectedAccount(SignInAccount.getAccount());

        DriveBuilder = new Drive.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), AccountCredential);
        DriveBuilder.setApplicationName(AppName);
        mDriveService = DriveBuilder.build();

        return true;
    }

    Log.d(TAG, "You have to signin by select account before use this call!");
    return false;
}
 
Example #2
Source File: LoginActivity.java    From TwrpBuilder with GNU General Public License v3.0 9 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == 1) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        try {
            GoogleSignInAccount account = task.getResult(ApiException.class);
            firebaseAuthWithGoogle(account);
        } catch (ApiException e) {
            Log.w("TAG", "Google sign in failed", e);
            // ...
        }
    }
}
 
Example #3
Source File: Manager.java    From react-native-fitness with MIT License 9 votes vote down vote up
public void subscribeToSteps(Context context, final Promise promise){
    final GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(context);
    if(account == null){
        promise.resolve(false);
        return;
    }
    Fitness.getRecordingClient(context, account)
            .subscribe(DataType.TYPE_STEP_COUNT_DELTA)
            .addOnSuccessListener(new OnSuccessListener<Void>() {
                @Override
                public void onSuccess(Void aVoid) {
                    promise.resolve(true);
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    promise.resolve(false);
                }
            });
}
 
Example #4
Source File: RestApiActivity.java    From google-services with Apache License 2.0 9 votes vote down vote up
@Override
public void onStart() {
    super.onStart();

    // Check if the user is already signed in and all required scopes are granted
    GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
    if (GoogleSignIn.hasPermissions(account, new Scope(CONTACTS_SCOPE))) {
        updateUI(account);
    } else {
        updateUI(null);
    }
}
 
Example #5
Source File: LoginActivity.java    From triviums with MIT License 8 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        try {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = task.getResult(ApiException.class);
            firebaseAuthWithGoogle(account);
        } catch (ApiException e) {
            // Google Sign In failed, update UI appropriately
            Log.w("TAG", "Google sign in failed", e);
        }

    }
}
 
Example #6
Source File: SignInActivity.java    From codelab-friendlychat-android with Apache License 2.0 8 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent in signIn()
    if (requestCode == RC_SIGN_IN) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        try {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = task.getResult(ApiException.class);
            firebaseAuthWithGoogle(account);
        } catch (ApiException e) {
            // Google Sign In failed, update UI appropriately
            Log.w(TAG, "Google sign in failed", e);
        }
    }
}
 
Example #7
Source File: MainActivity.java    From Android-9-Development-Cookbook with MIT License 8 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == REQUEST_SIGN_IN) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        try {
            GoogleSignInAccount account = task.getResult(ApiException.class);
            findViewById(R.id.signInButton).setVisibility(View.GONE);
            Toast.makeText(this, "Logged in:"+account.getDisplayName(), Toast.LENGTH_SHORT)
                    .show();
        } catch (ApiException e) {
            e.printStackTrace();
            Toast.makeText(this, "Sign in failed:"+e.getLocalizedMessage(), Toast.LENGTH_SHORT)
                    .show();
        }
    }
}
 
Example #8
Source File: BaseDemoActivity.java    From android-samples with Apache License 2.0 8 votes vote down vote up
/**
 * Starts the sign-in process and initializes the Drive client.
 */
protected void signIn() {
    Set<Scope> requiredScopes = new HashSet<>(2);
    requiredScopes.add(Drive.SCOPE_FILE);
    requiredScopes.add(Drive.SCOPE_APPFOLDER);
    GoogleSignInAccount signInAccount = GoogleSignIn.getLastSignedInAccount(this);
    if (signInAccount != null && signInAccount.getGrantedScopes().containsAll(requiredScopes)) {
        initializeDriveClient(signInAccount);
    } else {
        GoogleSignInOptions signInOptions =
                new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                  .requestScopes(Drive.SCOPE_FILE)
                  .requestScopes(Drive.SCOPE_APPFOLDER)
                  .build();
        GoogleSignInClient googleSignInClient = GoogleSignIn.getClient(this, signInOptions);
        startActivityForResult(googleSignInClient.getSignInIntent(), REQUEST_CODE_SIGN_IN);
    }
}
 
Example #9
Source File: BaseDemoActivity.java    From android-samples with Apache License 2.0 7 votes vote down vote up
/**
 * Handles resolution callbacks.
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
        case REQUEST_CODE_SIGN_IN:
            if (resultCode != RESULT_OK) {
                // Sign-in may fail or be cancelled by the user. For this sample, sign-in is
                // required and is fatal. For apps where sign-in is optional, handle
                // appropriately
                Log.e(TAG, "Sign-in failed.");
                finish();
                return;
            }

            Task<GoogleSignInAccount> getAccountTask =
                GoogleSignIn.getSignedInAccountFromIntent(data);
            if (getAccountTask.isSuccessful()) {
                initializeDriveClient(getAccountTask.getResult());
            } else {
                Log.e(TAG, "Sign-in failed.");
                finish();
            }
            break;
        case REQUEST_CODE_OPEN_ITEM:
            if (resultCode == RESULT_OK) {
                DriveId driveId = data.getParcelableExtra(
                        OpenFileActivityOptions.EXTRA_RESPONSE_DRIVE_ID);
                mOpenItemTaskSource.setResult(driveId);
            } else {
                mOpenItemTaskSource.setException(new RuntimeException("Unable to open file"));
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example #10
Source File: SettingsFragment.java    From YTPlayer with GNU General Public License v3.0 7 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode==103) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        try {
            GoogleSignInAccount account = task.getResult(ApiException.class);
            firebaseAuthWithGoogle(account);
        } catch (ApiException e) {
            Toast.makeText(activity, "Failed to sign in, Error: "+e.getStatusCode(), Toast.LENGTH_SHORT).show();
            e.printStackTrace();
            Log.e(TAG, "signInResult:failed code=" + e.getStatusCode());
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example #11
Source File: GoogleProvider.java    From SEAL-Demo with MIT License 7 votes vote down vote up
/**
 * Handle Activity Result for Google login
 * @param requestCode Request code
 * @param resultCode Actual result code from the request
 * @param data Additional data from the result
 */
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    // The Task returned from this call is always completed, no need to attach a listener.
    Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);

    if (resultCode == Activity.RESULT_OK) {
        handleSignInResult(task);
    } else {
        Log.e(TAG, "Sign in error: ", task.getException());
    }
}
 
Example #12
Source File: GoogleAccountsProvider.java    From science-journal with Apache License 2.0 7 votes vote down vote up
@Override
public void onLoginAccountsChanged(Intent data) {
  try {
    Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
    GoogleSignInAccount account = task.getResult(ApiException.class);
    GoogleSignInAccount googleSignInAccount = GoogleSignIn.getLastSignedInAccount(context);
    signInCurrentAccount(googleSignInAccount);
  } catch (ApiException apiException) {
    Log.e(TAG, "GoogleSignIn api exception");
  }
}
 
Example #13
Source File: GoogleSignInActivity.java    From wear-os-samples with Apache License 2.0 7 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log.d(TAG, "Activity request code: " + requestCode);
    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == REQUEST_CODE_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);
    }
}
 
Example #14
Source File: SignInActivity.java    From budgetto with MIT License 7 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == RC_SIGN_IN) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        try {
            GoogleSignInAccount account = task.getResult(ApiException.class);
            firebaseAuthWithGoogle(account);
        } catch (ApiException e) {
            e.printStackTrace();
            hideProgressView();
            loginError("Google sign in failed.");
        }
    }
}
 
Example #15
Source File: RNGoogleSigninModule.java    From google-signin with MIT License 7 votes vote down vote up
@Override
public void onActivityResult(Activity activity, final int requestCode, final int resultCode, final Intent intent) {
    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(intent);
        handleSignInTaskResult(task);
    } else if (requestCode == REQUEST_CODE_RECOVER_AUTH) {
        if (resultCode == Activity.RESULT_OK) {
            rerunFailedAuthTokenTask();
        } else {
            promiseWrapper.reject(MODULE_NAME, "Failed authentication recovery attempt, probably user-rejected.");
        }
    }
}
 
Example #16
Source File: Manager.java    From react-native-fitness with MIT License 6 votes vote down vote up
public void subscribeToActivity(Context context, final Promise promise){
    final GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(context);
    if(account == null){
        promise.resolve(false);
        return;
    }
    Fitness.getRecordingClient(context, account)
            .subscribe(DataType.TYPE_ACTIVITY_SAMPLES)
            .addOnSuccessListener(new OnSuccessListener<Void>() {
                @Override
                public void onSuccess(Void aVoid) {
                    promise.resolve(true);
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    promise.resolve(false);
                }
            });

}
 
Example #17
Source File: SignInActivity.java    From Duolingo-Clone with MIT License 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == RC_SIGN_IN) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        try {

            GoogleSignInAccount account = task.getResult(ApiException.class);
            firebaseAuthWithGoogle(account);

        } catch (ApiException e) {

            Toast.makeText(context, getString(R.string.auth_failed), Toast.LENGTH_SHORT).show();
        }
    }
}
 
Example #18
Source File: GoogleAuthTest.java    From gdx-fireapp with Apache License 2.0 6 votes vote down vote up
@Test
    public void signOut_fail() {
        // Given
        GoogleAuth googleAuth = new GoogleAuth();
        Task task = Mockito.mock(Task.class);
        final Task task2 = Mockito.mock(Task.class);
        Mockito.when(task2.isSuccessful()).thenReturn(false);
        Mockito.when(googleSignInClient.signOut()).thenReturn(task);
        Mockito.when(task.addOnCompleteListener(Mockito.any(OnCompleteListener.class))).thenAnswer(new Answer<Object>() {
            @Override
            public Object answer(InvocationOnMock invocation) {
                ((OnCompleteListener) invocation.getArgument(0)).onComplete(task2);
                return null;
            }
        });

        // When
        FuturePromise promise = (FuturePromise) PowerMockito.spy(googleAuth.signOut().silentFail().subscribe());

        // Then
        PowerMockito.verifyStatic(GoogleSignIn.class, VerificationModeFactory.times(1));
        GoogleSignIn.getClient((Activity) Mockito.refEq(Gdx.app), Mockito.any(GoogleSignInOptions.class));
        Mockito.verify(googleSignInClient, VerificationModeFactory.times(1)).signOut();
//        Mockito.verify(promise, VerificationModeFactory.times(1)).doFail(Mockito.nullable(Exception.class));
    }
 
Example #19
Source File: GoogleSignInActivity.java    From quickstart-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        try {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = task.getResult(ApiException.class);
            Log.d(TAG, "firebaseAuthWithGoogle:" + account.getId());
            firebaseAuthWithGoogle(account.getIdToken());
        } catch (ApiException e) {
            // Google Sign In failed, update UI appropriately
            Log.w(TAG, "Google sign in failed", e);
            // [START_EXCLUDE]
            updateUI(null);
            // [END_EXCLUDE]
        }
    }
}
 
Example #20
Source File: RestApiActivity.java    From google-services with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        handleSignInResult(task);
    }

    // Handling a user-recoverable auth exception
    if (requestCode == RC_RECOVERABLE) {
        if (resultCode == RESULT_OK) {
            getContacts();
        } else {
            Toast.makeText(this, R.string.msg_contacts_failed, Toast.LENGTH_SHORT).show();
        }
    }
}
 
Example #21
Source File: MainActivity.java    From android-basic-samples with Apache License 2.0 6 votes vote down vote up
private boolean isSignedIn() {
  return GoogleSignIn.getLastSignedInAccount(this) != null;
}
 
Example #22
Source File: GoogleAuthTest.java    From gdx-fireapp with Apache License 2.0 6 votes vote down vote up
@Test
    public void revokeAccess_fail() {
        // Given
        GoogleAuth googleAuth = new GoogleAuth();
        Task task = Mockito.mock(Task.class);
        final Task task2 = Mockito.mock(Task.class);
        Mockito.when(task2.isSuccessful()).thenReturn(false);
        Mockito.when(googleSignInClient.revokeAccess()).thenReturn(task);
        Mockito.when(task.addOnCompleteListener(Mockito.any(OnCompleteListener.class))).thenAnswer(new Answer<Object>() {
            @Override
            public Object answer(InvocationOnMock invocation) {
                ((OnCompleteListener) invocation.getArgument(0)).onComplete(task2);
                return null;
            }
        });

        // When
        FuturePromise promise = (FuturePromise) spy(googleAuth.revokeAccess().silentFail().subscribe());

        // Then
        PowerMockito.verifyStatic(GoogleSignIn.class, VerificationModeFactory.times(1));
        GoogleSignIn.getClient((Activity) Mockito.refEq(Gdx.app), Mockito.any(GoogleSignInOptions.class));
        Mockito.verify(googleSignInClient, VerificationModeFactory.times(1)).revokeAccess();
//        Mockito.verify(promise, VerificationModeFactory.times(1)).doFail(Mockito.nullable(Exception.class));
    }
 
Example #23
Source File: MainActivity.java    From NaviBee with GNU General Public License v3.0 6 votes vote down vote up
private void logOut() {
    // sign out firebase
    NaviBeeApplication.getInstance().uninit();

    FirebaseAuth.getInstance().signOut();

    // sign out google login
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.default_web_client_id))
            .requestEmail()
            .build();
    GoogleSignIn.getClient(this, gso).signOut();

    // reset token to prevent further messages
    try {
        FirebaseInstanceId.getInstance().deleteInstanceId();
    } catch (Exception e) {
        Timber.e(e, "Error occurred while resetting tokens.");
    }


    Intent intent = new Intent(this, LoginActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME);
    startActivity(intent);
    this.finish();
}
 
Example #24
Source File: PlayGamesPlugin.java    From play_games with MIT License 6 votes vote down vote up
private GoogleSignInAccount getLastSignedInAccount() {
    return GoogleSignIn.getLastSignedInAccount(registrar.activity());
}
 
Example #25
Source File: UserFragment.java    From android-kubernetes-blockchain with Apache License 2.0 6 votes vote down vote up
@Override
public void onRefresh() {
    refreshRunnable = new Runnable() {
        @Override
        public void run() {
            getStateOfUser(userIdFromStorage);

            // refresh google fit history
            if (!GoogleSignIn.hasPermissions(GoogleSignIn.getLastSignedInAccount((AppCompatActivity) getActivity()))) {
                Log.d(TAG, "Not signed in...");
            } else {
                accessGoogleFit();
            }
        }
    };

    handler.postDelayed(refreshRunnable,5000);
}
 
Example #26
Source File: GoogleAccountsProvider.java    From science-journal with Apache License 2.0 6 votes vote down vote up
@Override
public int getAccountCount() {
  GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(context);
  return account == null ? 0 : 1;
}
 
Example #27
Source File: MainActivity.java    From android-basic-samples with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

  log("onCreate.");
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  // Create the client used to sign in.
  mGoogleSignInClient = GoogleSignIn.getClient(this,
      new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
          // Since we are using SavedGames, we need to add the SCOPE_APPFOLDER to access Google Drive.
          .requestScopes(Drive.SCOPE_APPFOLDER)
          .build());

  for (int id : LEVEL_BUTTON_IDS) {
    findViewById(id).setOnClickListener(this);
  }
  findViewById(R.id.button_next_world).setOnClickListener(this);
  findViewById(R.id.button_prev_world).setOnClickListener(this);
  findViewById(R.id.button_sign_in).setOnClickListener(this);
  findViewById(R.id.button_sign_out).setOnClickListener(this);
  ((RatingBar) findViewById(R.id.gameplay_rating)).setOnRatingBarChangeListener(this);
  mSaveGame = new SaveGame();
  updateUi();
  checkPlaceholderIds();
}
 
Example #28
Source File: GoogleProviderHandler.java    From capacitor-firebase-auth with MIT License 6 votes vote down vote up
@Override
public void handleOnActivityResult(int requestCode, int resultCode, Intent data) {
    Log.d(GOOGLE_TAG, "Google SignIn activity result.");

    try {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        // Google Sign In was successful, authenticate with Firebase
        GoogleSignInAccount account = task.getResult(ApiException.class);

        if (account != null) {
            Log.d(GOOGLE_TAG, "Google Sign In succeed.");
            AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null);
            this.plugin.handleAuthCredentials(credential);
            return;
        }
    } catch (ApiException exception) {
        // Google Sign In failed, update UI appropriately
        Log.w(GOOGLE_TAG, GoogleSignInStatusCodes.getStatusCodeString(exception.getStatusCode()), exception);
        plugin.handleFailure("Google Sign In failure.", exception);
        return;
    }

    plugin.handleFailure("Google Sign In failure.", null);
}
 
Example #29
Source File: SignInActivity.java    From codelab-friendlychat-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent in signIn()
    if (requestCode == RC_SIGN_IN) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        try {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = task.getResult(ApiException.class);
            firebaseAuthWithGoogle(account);
        } catch (ApiException e) {
            // Google Sign In failed, update UI appropriately
            Log.w(TAG, "Google sign in failed", e);
        }
    }
}
 
Example #30
Source File: SignInActivity.java    From codelab-friendlychat-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sign_in);

    // Assign fields
    mSignInButton = (SignInButton) findViewById(R.id.sign_in_button);

    // Set click listeners
    mSignInButton.setOnClickListener(this);

    // Configure Google Sign In
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.default_web_client_id))
            .requestEmail()
            .build();
    mSignInClient = GoogleSignIn.getClient(this, gso);

    // Initialize FirebaseAuth
    mFirebaseAuth = FirebaseAuth.getInstance();
}