Created
July 24, 2021 14:30
-
-
Save AbhishekDoshi26/d150efac15039684e3865f851ff65533 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.os.Bundle; | |
import io.flutter.app.FlutterActivity; | |
import io.flutter.plugin.common.MethodCall; | |
import io.flutter.plugin.common.MethodChannel; | |
import io.flutter.plugins.GeneratedPluginRegistrant; | |
public class MainActivity extends FlutterActivity { | |
private static final String CHANNEL = "flutter.native/helperChannel"; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
GeneratedPluginRegistrant.registerWith(this); | |
new MethodChannel(getFlutterView(), CHANNEL).setMethodCallHandler( | |
new MethodChannel.MethodCallHandler() { | |
@Override | |
public void onMethodCall(MethodCall call, MethodChannel.Result result) { | |
if (call.method.equals("helloFromNativeCode")) { | |
String greetings = helloFromNativeCode(); | |
result.success(greetings); | |
} | |
}}); | |
} | |
private String helloFromNativeCode() { | |
return "Hello from Native Android Code"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment