I was asked to help creating a wrapper for TapKey Securitykeys.
They provide sample Androidapplication in which they are using lambda.
https://developers.tapkey.io/mobile/android/getting_started/
The Example app can be found here: https://github.com/tapkey/android-s...src/main/java/net/tpky/demoapp/authentication
In the mainactivity it starts with a check.
https://github.com/tapkey/android-s.../main/java/net/tpky/demoapp/MainActivity.java
How can i use such code in my wrapper?
Do i need to develop the library with Android Studio? As of now i am using Eclipse for syntaxhelp and SLC to compile.
I can into an error in SLC for sure
Any suggestions/hints?
PD: The Device used is using Android 7+
They provide sample Androidapplication in which they are using lambda.
https://developers.tapkey.io/mobile/android/getting_started/
The Example app can be found here: https://github.com/tapkey/android-s...src/main/java/net/tpky/demoapp/authentication
In the mainactivity it starts with a check.
https://github.com/tapkey/android-s.../main/java/net/tpky/demoapp/MainActivity.java
B4X:
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
private static final String TAG = MainActivity.class.getSimpleName();
private UserManager userManager;
private Auth0PasswordIdentityProvider passwordIdentityProvider;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*
* Retrieve the TapkeyServiceFactory singleton.
*/
App app = (App) getApplication();
TapkeyServiceFactory tapkeyServiceFactory = app.getTapkeyServiceFactory();
ConfigManager configManager = tapkeyServiceFactory.getConfigManager();
userManager = tapkeyServiceFactory.getUserManager();
passwordIdentityProvider = app.getPasswordIdentityProvider();
/*
* When no user is signed in, redirect to login LoginActivity
*/
if(!userManager.hasUsers()){
Intent intent = new Intent(this, LoginActivity.class);
startActivity(intent);
finish();
return;
}
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
View headerView = navigationView.getHeaderView(0);
TextView usernameTextView = (TextView) headerView.findViewById(R.id.nav_header__username);
/*
* Get the username of first user and display it in side menu. The first user is used here,
* because we don't support multi-user yet anyways.
*/
User firstUser = userManager.getFirstUser();
if(firstUser != null){
usernameTextView.setText(firstUser.getIpUserName());
}
/*
* Verify, that app is compatible
*/
configManager.getAppState(CancellationTokens.None)
// asynchronously receive the operation result on the UI thread
.continueOnUi((Func1<ConfigManager.AppState, Void, Exception>) appState -> {
// some time might have passed and maybe the activity is already finishing.
if (isFinishing())
return null;
switch (appState) {
// SDK Version is not supported anymore
case CLIENT_TOO_OLD:
new AlertDialog.Builder(MainActivity.this)
.setMessage(R.string.main_app_too_old)
.setPositiveButton(R.string.app_too_old_button, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
finish();
}
})
.setOnDismissListener(dialogInterface -> {
// TODO: Redirect to the app store, to let the user
// download the latest app version.
finish();
})
.create()
.show();
break;
// This version of the SDK is still supported but is short before expiring and should be updated.
case CLIENT_UPDATE_SUGGESTED:
new AlertDialog.Builder(MainActivity.this)
.setMessage(R.string.newer_app_available)
.setPositiveButton(R.string.newer_app_available_button, null)
.create()
.show();
break;
case CLIENT_VERSION_OK:
default:
}
return null;
})
// Handle exceptions raised in async code.
.catchOnUi(e -> {
// Handle error
Log.e(TAG, "failed to fetch app state: ", e);
return null;
})
// Make sure, no exceptions get lost.
.conclude();
}
How can i use such code in my wrapper?
Do i need to develop the library with Android Studio? As of now i am using Eclipse for syntaxhelp and SLC to compile.
I can into an error in SLC for sure
E:\B4ALibs.workspace\TapKeySDK\src\de\donmanfred\TapKeyAppwrapper.java:60: error: lambda expressions are not supported in -source 7
AsyncSchedulers.setSchedulerInterceptor((x, name) -> AsyncSchedulerUtils.applyLogging(x, name, 500, 10000));
^
(use -source 8 or higher to enable lambda expressions)
1 error
javac 11.0.1
Error.
Any suggestions/hints?
PD: The Device used is using Android 7+
Last edited: