Does anyone has knowledge about Smart Lock? How does it works?
I want to develop an application implementing Smart Lock for passwords in Android application.
I am following https://developers.google.com/identity/smartlock-passwords/android/.
I have initialized GoogleApiClient
mCredentialsApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Auth.CREDENTIALS_API)
.build();
and generated instance of Credential
as
final Credential credential = new Credential.Builder(email)
.setPassword(password)
.build();
to save credentials using Credentials API
, I used
Auth.CredentialsApi.save(mCredentialsClient, credential).setResultCallback(
new ResultCallback() {
@Override
public void onResult(Status status) {
if (status.isSuccess()) {
// Credentials were saved
} else {
if (status.hasResolution()) {
// Try to resolve the save request. This will prompt the user if
// the credential is new.
try {
status.startResolutionForResult(this, RC_SAVE);
} catch (IntentSender.SendIntentException e) {
// Could not resolve the request
}
}
}
}
});
my Manifest
has the permission as
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
and also added Meta data
inside application tag as
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
after doing all in Android application, I have generated project on Google Developer Console
and have done everything as mentioned in this link here.
But when I run project, I am getting an error as:
Could not resolve error.
Has anyone worked on Google's Smart Lock for Password on Android application?
For me, the Smart Lock for Passwords on Android sample project worked fine. You might want to try starting from there and see if that helps. In the sample code, save credential is implemented as:
In
onCreate
:... In the
saveCredetial
method:... The
resolveResult
method on the main activity: