Начал разбираться с вызовом специфичной для андроида Activity
This commit is contained in:
@@ -28,5 +28,8 @@
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".CameraActivity"
|
||||
android:theme="@android:style/Theme.Black.NoTitleBar"/>
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yourcompany.checker;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.yourcompany.checker.R;
|
||||
|
||||
public class CameraActivity extends Activity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.a_scanner);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,38 @@
|
||||
package com.yourcompany.checker;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import com.yourcompany.checker.CameraActivity;
|
||||
|
||||
import io.flutter.app.FlutterActivity;
|
||||
import io.flutter.plugins.GeneratedPluginRegistrant;
|
||||
|
||||
import io.flutter.plugin.common.MethodCall;
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
|
||||
import io.flutter.plugin.common.MethodChannel.Result;
|
||||
|
||||
public class MainActivity extends FlutterActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
GeneratedPluginRegistrant.registerWith(this);
|
||||
}
|
||||
|
||||
private static final String CHANNEL = "samples.flutter.io/battery";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
GeneratedPluginRegistrant.registerWith(this);
|
||||
new MethodChannel(getFlutterView(), CHANNEL).setMethodCallHandler(
|
||||
new MethodCallHandler() {
|
||||
@Override
|
||||
public void onMethodCall(MethodCall call, Result result) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void startScanner() {
|
||||
Log.d("kifio", "Start scanner");
|
||||
startActivity(new Intent(MainActivity.this, CameraActivity.class));
|
||||
}
|
||||
|
||||
}
|
||||
7
android/app/src/main/res/layout/a_scanner.xml
Normal file
7
android/app/src/main/res/layout/a_scanner.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/rootLayout"
|
||||
android:background="@android:color/white"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
@@ -1,4 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
const String _name = "Ivan Murashov";
|
||||
|
||||
@@ -18,6 +21,7 @@ class ChatScreen extends StatefulWidget {
|
||||
|
||||
class ChatScreenState extends State<ChatScreen> {
|
||||
|
||||
static const platform = const MethodChannel('samples.flutter.io/battery');
|
||||
final List<ChatMessage> _messages = <ChatMessage>[];
|
||||
final TextEditingController _textController = new TextEditingController();
|
||||
|
||||
@@ -64,10 +68,19 @@ class ChatScreenState extends State<ChatScreen> {
|
||||
decoration: textField)),
|
||||
new Container(margin: new EdgeInsets.symmetric(horizontal: 4.0),
|
||||
child: new IconButton(icon: new Icon(Icons.send),
|
||||
onPressed: () => _handleSubmitted(_textController.text)))
|
||||
onPressed: () => startScanner()))
|
||||
// onPressed: () => _handleSubmitted(_textController.text)))
|
||||
]);
|
||||
}
|
||||
|
||||
Future<Null> startScanner() async {
|
||||
try {
|
||||
platform.invokeMethod('startScanner');
|
||||
} on PlatformException catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void _handleSubmitted(String text) {
|
||||
_textController.clear();
|
||||
ChatMessage message = new ChatMessage(text);
|
||||
|
||||
Reference in New Issue
Block a user