@@ -39,26 +39,25 @@ public class InstabugFlutterPlugin implements FlutterPlugin, ActivityAware {
39
39
* Embedding v1
40
40
* This method is required for compatibility with apps that don't use the v2 embedding.
41
41
*/
42
- // Uncomment this method for backward compatibility
43
-
44
- // @SuppressWarnings("deprecation")
45
- // public static void registerWith(Object registrar) {
46
- // try {
47
- // // Use reflection to access the Registrar class and its methods
48
- // Class<?> registrarClass = Class.forName("io.flutter.plugin.common.PluginRegistry.Registrar");
49
- // Activity activity = (Activity) registrarClass.getMethod("activity").invoke(registrar);
50
- // Context context = (Context) registrarClass.getMethod("context").invoke(registrar);
51
- // BinaryMessenger messenger = (BinaryMessenger) registrarClass.getMethod("messenger").invoke(registrar);
52
- // FlutterRenderer renderer = (FlutterRenderer) registrarClass.getMethod("textures").invoke(registrar);
53
- //
54
- // // Set the activity and register with the context
55
- // InstabugFlutterPlugin.activity = activity;
56
- // registerWithContext(context.getApplicationContext(), messenger, renderer);
57
- // System.out.println("old app");
58
- // } catch (Exception e) {
59
- // Log.e(TAG, "Failed to register with v1 embedding. Cause: " + e);
60
- // }
61
- // }
42
+
43
+ @ SuppressWarnings ("deprecation" )
44
+ public static void registerWith (Object registrar ) {
45
+ try {
46
+ // Use reflection to access the Registrar class and its methods
47
+ Class <?> registrarClass = Class .forName ("io.flutter.plugin.common.PluginRegistry.Registrar" );
48
+ Activity activity = (Activity ) registrarClass .getMethod ("activity" ).invoke (registrar );
49
+ Context context = (Context ) registrarClass .getMethod ("context" ).invoke (registrar );
50
+ BinaryMessenger messenger = (BinaryMessenger ) registrarClass .getMethod ("messenger" ).invoke (registrar );
51
+ FlutterRenderer renderer = (FlutterRenderer ) registrarClass .getMethod ("textures" ).invoke (registrar );
52
+
53
+ // Set the activity and register with the context
54
+ InstabugFlutterPlugin .activity = activity ;
55
+ registerWithContext (context .getApplicationContext (), messenger , renderer );
56
+ System .out .println ("old app" );
57
+ } catch (Exception e ) {
58
+ Log .e (TAG , "Failed to register with v1 embedding. Cause: " + e );
59
+ }
60
+ }
62
61
63
62
@ Override
64
63
public void onAttachedToEngine (@ NonNull FlutterPluginBinding binding ) {
0 commit comments