-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
Description
I just ran across this in my app where I'm trying to use the compat library's BiometricPrompt (or is it AndroidX library now) which requires a FragmentActivity.
FlutterFragmentActivity currently uses the old support libraries rather than the new ones which means I couldn't use it.
My temporary workaround is to basically copy-paste the code out of FlutterFragmentActivity.java and change the support libraries to androidx:
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentActivity;
import io.flutter.app.FlutterActivityDelegate;
import io.flutter.app.FlutterActivityEvents;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.view.FlutterNativeView;
import io.flutter.view.FlutterView;
public class FlutterFragmentxActivity extends FragmentActivity implements FlutterView.Provider, PluginRegistry, FlutterActivityDelegate.ViewFactory {
private final FlutterActivityDelegate delegate = new FlutterActivityDelegate(this, this);
private final FlutterActivityEvents eventDelegate;
private final FlutterView.Provider viewProvider;
private final PluginRegistry pluginRegistry;
public FlutterFragmentxActivity() {
this.eventDelegate = this.delegate;
this.viewProvider = this.delegate;
this.pluginRegistry = this.delegate;
}
@Override
public FlutterView getFlutterView() {
return this.viewProvider.getFlutterView();
}
@Override
public FlutterView createFlutterView(Context context) {
return null;
}
@Override
public FlutterNativeView createFlutterNativeView() {
return null;
}
@Override
public boolean retainFlutterNativeView() {
return false;
}
@Override
public final boolean hasPlugin(String key) {
return this.pluginRegistry.hasPlugin(key);
}
@Override
public final <T> T valuePublishedByPlugin(String pluginKey) {
return this.pluginRegistry.valuePublishedByPlugin(pluginKey);
}
@Override
public final Registrar registrarFor(String pluginKey) {
return this.pluginRegistry.registrarFor(pluginKey);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.eventDelegate.onCreate(savedInstanceState);
}
@Override
protected void onDestroy() {
this.eventDelegate.onDestroy();
super.onDestroy();
}
@Override
public void onBackPressed() {
if (!this.eventDelegate.onBackPressed()) {
super.onBackPressed();
}
}
@Override
protected void onStart() {
super.onStart();
this.eventDelegate.onStart();
}
@Override
protected void onStop() {
this.eventDelegate.onStop();
super.onStop();
}
@Override
protected void onPause() {
super.onPause();
this.eventDelegate.onPause();
}
@Override
protected void onPostResume() {
super.onPostResume();
this.eventDelegate.onPostResume();
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
this.eventDelegate.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (!this.eventDelegate.onActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
}
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
this.eventDelegate.onNewIntent(intent);
}
@Override
public void onUserLeaveHint() {
this.eventDelegate.onUserLeaveHint();
}
@Override
public void onTrimMemory(int level) {
this.eventDelegate.onTrimMemory(level);
}
@Override
public void onLowMemory() {
this.eventDelegate.onLowMemory();
}
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
this.eventDelegate.onConfigurationChanged(newConfig);
}
}
Metadata
Metadata
Assignees
Labels
No labels