How to bring app to foreground in flutter integration test - android

I have an integration test which taps a text of phone number, then it opens the phone dial app which makes my app put to background.
final firstNumber = find.byWidgetPredicate(
(widget) => widget is RichText && tapTextSpan(widget, '09123456789'));
await tester.tap(firstNumber);
After tester.tap() it successfully open the built in dial app in phone.
How can I bring my app to foreground?
Package used: integration_test, flutter_test

You can use flutter_foreground_task package
use FlutterForegroundTask.minimizeApp() for app to background
and FlutterForegroundTask.launchApp() for app to foreground
that's all. I hope it helps.

Related

How to make a flutter app run in background?

I am developing an app which uses an embedded system connected to through Bluetooth to an embedded device and I want the app to run a function when the device sends a signal.
The issue is that I cannot keep the app open all the time and thus need the app to keep running in the background and keep listening for the signal send by the embedded device so that it can run the function I want.
I have seen the following questions :
How to run flutter app in background continually?
How can I make my flutter app run in background without stopping?
How to create a service in Flutter to make an app to run always in background?
and many more and so far nothing seems to work.
I have written this code for now :
Future<void> _run_app_in_background() async {
final config = FlutterBackgroundAndroidConfig(
notificationTitle: 'MEDICA',
notificationText:
'MEDICA is running in the background',
notificationIcon: AndroidResource(name: 'background_icon'),
notificationImportance: AndroidNotificationImportance.Default,
);
var hasPermissions = await FlutterBackground.hasPermissions;
hasPermissions = await FlutterBackground.initialize(androidConfig: config);
final backgroundExecution =
await FlutterBackground.enableBackgroundExecution();
}
but it seems to be doing nothing and the same with other packages.
So how can I make my app run in background to keep listening for the Bluetooth data sent by device.
Edit:I want this to run on both Android and iOS and if possible maybe someone can suggest me another framework apart from Flutter (in comments maybe) and I can search the internet for the same.
#HrishabhNayal Hello bro Try this way!
https://medium.com/dlt-labs-publication/flutter-run-code-in-the-background-461b4d6c635b

android listen to notification of default dialer app

I am working on an app like the true caller. I want to listen only to that notification that is coming from the default phone dialer app. I Have checked this, this but didn't get the right answer. My task is I want to open a dialogue box only where there is an incoming caller. I tried the following code if the package name has the string dialer through the following code.
const handleNotificationReceived = notification => {
if(notification.app.substr(notification.app.length - 6) === 'dialer'){
setNum(notification.title)
onAdd(num);
setLastNotification(notification);
}
};
I need this on android 5 and higher. Also, I am using React Native so if there is any solution in react native or android is highly appreciated.

How to show an incoming call when screen is locked on react-native

I'm developing a video call app with react-native-webrtc and I'm stuck now on how to show the incoming call screen when the phone is locked. I'm working now on the android part and I already tried this tutorial but it doesn't work for me https://medium.com/#shivanshrajpoot/create-a-react-native-app-which-works-on-lock-screen-android-b127f0177455
Thanks in advance :)
React Native CallKeep is what you need.
You can find the usage details here..
https://github.com/react-native-webrtc/react-native-callkeep
To display an incoming call screen when the screen is locked in a React Native app, you can use the react-native-incoming-call package. Here's a simple example:
Install the package using npm or yarn:
npm install react-native-incoming-call
or
yarn add react-native-incoming-call
Import the package in your React Native code:
import IncomingCall from 'react-native-incoming-call';
Show the incoming call screen when you receive an incoming call event:
IncomingCall.show({
callTitle: 'Incoming Call',
contactName: 'John Doe',
avatar: 'https://picsum.photos/100',
onDecline: () => {},
onAccept: () => {}
});
Here, callTitle and contactName are the title and name of the incoming call, respectively, while avatar is an optional profile picture. onDecline and onAccept are the callbacks that will be called when the user declines or accepts the call, respectively.
This should give you an idea of how to show an incoming call screen when the screen is locked in React Native. You can further customize this code to meet your specific needs.

How to check if certain intent has started

How to check if intent or app has started ?
My use case is I am showing up notifications through my app and I want to clear them all via myBuilder.cancelAll() if default messaging app has started since my app shows sms notifications. So I am kind of looking for something like:
if (smsAppStarted) {
myBuilder.cancelAll();
}
Thanks
To check if an app has started:
Get the package name of the sms app you want to check.
Then refer to my answer here:
Android how to know an app has been started and range apps priority according the starting times
By using that code, the list taskInfo will contain the list of all apps currently running. Search that list using the package name of the sms app. If it is present in that list, it means that that app has started and currently running.
If I get you right, you need to determine, if another app is currently running. If so, then use this solution.

Sony SmartWatch widget only or widget and control extension?

As part of the free SmartWatch promotion I got a watch from Sony and have published an app for it. It is called SoundCheck and is found through the LiveWare Manager on the Google Play Market. A customer recently sent email for support. They installed Sound Check but did not see it on the watch since widgets are not enabled by default when they are installed. Is there any way to programmatically enable a widget when an app is installed? It might be nice for users if the widget was enabled by default rather than force them to navigate through the LiveWare manager to find the setting. This would be quite helpful for "widget-only" apps like Sound Check that do not have a control extension.
This week I created a pro version of my SmartWatch app to actually change the values displayed by the widget. Is it possible to open a control extension from a widget extension? Here is the use case. Short taps navigate through different screens of the widget. I want to use the long tap event type on the widget to open the 'editing' function in the control extension. Is this possible?
Thanks in advance for your help with these questions.
The question of how to enable a widget programmatically is still open. Here is code to open the control from a widget. This answer helped:
How should I do to start SmartWatch Extension from the program code?
if (type == Widget.Intents.EVENT_TYPE_SHORT_TAP) {
updateWidget();
} else {
//this code will launch the control and allow the user to change volume settings?
Intent intent = new Intent(Control.Intents.CONTROL_START_REQUEST_INTENT);
intent.putExtra(Control.Intents.EXTRA_AEA_PACKAGE_NAME, "com.mezcode.soundcheckpro");
intent.setPackage(mHostAppPackageName);
mContext.sendBroadcast(intent, Registration.HOSTAPP_PERMISSION);
}

Categories

Resources