10000 Add flutter_background, fix screen capture simple for Android. · next-coder/flutter-webrtc@0c21fa5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0c21fa5

Browse files
committed
Add flutter_background, fix screen capture simple for Android.
1 parent 128f313 commit 0c21fa5

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

example/lib/main.dart

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'dart:core';
33
import 'package:flutter/foundation.dart'
44
show debugDefaultTargetPlatformOverride;
55
import 'package:flutter/material.dart';
6-
import 'package:flutter_foreground_plugin/flutter_foreground_plugin.dart';
6+
import 'package:flutter_background/flutter_background.dart';
77
import 'package:flutter_webrtc/flutter_webrtc.dart';
88

99
import 'src/data_channel_sample.dart';
@@ -24,25 +24,15 @@ void main() {
2424
}
2525

2626
Future<bool> startForegroundService() async {
27-
await FlutterForegroundPlugin.setServiceMethodInterval(seconds: 5);
28-
await FlutterForegroundPlugin.setServiceMethod(globalForegroundService);
29-
await FlutterForegroundPlugin.startForegroundService(
30-
holdWakeLock: false,
31-
onStarted: () {
32-
print('Foreground on Started');
33-
},
34-
onStopped: () {
35-
print('Foreground on Stopped');
36-
},
37-
title: 'Tcamera',
38-
content: 'Tcamera sharing your screen.',
39-
iconName: 'ic_stat_mobile_screen_share',
27+
final androidConfig = FlutterBackgroundAndroidConfig(
28+
notificationTitle: 'Title of the notification',
29+
notificationText: 'Text of the notification',
30+
notificationImportance: AndroidNotificationImportance.Default,
31+
notificationIcon: AndroidResource(
32+
name: 'background_icon',
33+
defType: 'drawable'), // Default is ic_launcher from folder mipmap
4034
);
41-
return true;
42-
}
43-
44-
void globalForegroundService() {
45-
debugPrint('current datetime is ${DateTime.now()}');
35+
return FlutterBackground.initialize(androidConfig: androidConfig);
4636
}
4737

4838
class MyApp extends StatefulWidget {

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies:
1010
cupertino_icons: ^1.0.2
1111
flutter:
1212
sdk: flutter
13-
flutter_foreground_plugin: ^0.8.0
13+
flutter_background: ^1.0.0
1414
flutter_webrtc:
1515
path: ../
1616
# Required for MediaRecorder example

0 commit comments

Comments
 (0)
0