Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (call.method.equals("getPlatformVersion")) {
- // val picker= TimePicker = view.findViewById(R.id.picker);
- try{
- Context context = pluginBinding.getApplicationContext();
- File aarFile = new File(context.getApplicationInfo().dataDir +"/Users/odunayoojomo/Desktop", "tappx-sdk-4.0.4.aar");
- if (!aarFile.exists()) {
- result.error("FILE_NOT_FOUND", "The .aar file does not exist.", null);
- return;
- }
- // Load the .aar file dynamically
- DexClassLoader classLoader = new DexClassLoader(aarFile.getAbsolutePath(), context.getCacheDir().getAbsolutePath(), null, context.getClassLoader());
- Class<?> aarClass = classLoader.loadClass("com.tappx.sdk.android.Tappx"); // Replace with the actual class from the .aar file
- // Create an instance of the loaded class
- Object instance = aarClass.newInstance();
- // Invoke methods or access fields from the loaded class
- // For example, assuming there is a method named "exampleMethod" in the class:
- Method method = aarClass.getDeclaredMethod("getVersion");
- Object returnValue = method.invoke(instance);
- if (returnValue instanceof String) {
- String resultString = (String) returnValue;
- System.out.println(resultString);
- result.success(resultString);
- } else {
- result.error("INVALID_RETURN_TYPE", "The invoked method did not return a String.", null);
- }
- }catch (Exception e) {
- result.error("CONNECT_ERROR", "Failed to connect to the .aar file: " + e.getMessage(), null);
- }
- } else {
- result.notImplemented();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement