activity.java 代码,Java LockActivity类代码示例
import com.auth0.lock.LockActivity; //导入依赖的package包/类/*** This method is exported to JS* Called from JS to show the Lock.Android login/signup activities. It will display the* corresponding activity ba
import com.auth0.lock.LockActivity; //导入依赖的package包/类
/**
* This method is exported to JS
* Called from JS to show the Lock.Android login/signup activities. It will display the
* corresponding activity based on the requested connections and other options.
*
* @param options the map with the values passed when invoked from JS. Some of the supported
* fields are "closable", "connections", "useMagicLink" and "authParams"
* @see com.auth0.lock.react.bridge.ShowOptions
* @param callback the JS callback that will be invoked with the results. It should be a function
* of the form callback(error, profile, token)
*/
@ReactMethod
public void show(@Nullable ReadableMap options, Callback callback) {
authCallback = callback;
authenticationReceiver.registerIn(this.broadcastManager);
ShowOptions showOptions = new ShowOptions(options);
lockBuilder
.closable(showOptions.isClosable())
.disableSignUp(showOptions.isDisableSignUp())
.disableChangePassword(showOptions.isDisableResetPassword())
.authenticationParameters(showOptions.getAuthParams());
if (showOptions.getConnections() != null) {
lockBuilder.useConnections(showOptions.getConnections());
}
LockContext.configureLock(lockBuilder);
Activity activity = getCurrentActivity();
if (activity == null) {
invokeAuthCallback(getReactApplicationContext().getString(R.string.com_auth0_android_react_native_lock_no_activity), null, null);
return;
}
Intent intent;
switch (showOptions.getConnectionType()) {
case CONNECTION_SMS:
intent = new Intent(activity, LockPasswordlessActivity.class);
intent.putExtra(LockPasswordlessActivity.PASSWORDLESS_TYPE_PARAMETER,
showOptions.useMagicLink()
? LockPasswordlessActivity.MODE_SMS_MAGIC_LINK
: LockPasswordlessActivity.MODE_SMS_CODE);
break;
case CONNECTION_EMAIL:
intent = new Intent(activity, LockPasswordlessActivity.class);
intent.putExtra(LockPasswordlessActivity.PASSWORDLESS_TYPE_PARAMETER,
showOptions.useMagicLink()
? LockPasswordlessActivity.MODE_EMAIL_MAGIC_LINK
: LockPasswordlessActivity.MODE_EMAIL_CODE);
break;
case CONNECTION_NATIVE:
default:
intent = new Intent(activity, LockActivity.class);
}
activity.startActivity(intent);
}
更多推荐


所有评论(0)