I'm trying to build a video calling app with Agora, I need to show acceptance screen like WhatsApp when user calling, if the app is exited i need to show calling screen when user is calling, I tried lot of thing but nothing works, I trying to do i flutter and but there is nothing much information on this,Please help me
- 
                    1You may start searching for concepts like "How to start activities from the background". From what I could understand in the question, the problem might be about restrictions doing that (https://developer.android.com/guide/components/activities/background-starts). I recommend you explaining more and adding code in your question: AndroidManifest.xml permissions, Activities used, the foreground Service you may have to be running, etc. – DNax Apr 27 '20 at 17:54
 - 
                    i have tried several codes,nothig seems to work,i need to everything in flutter,the app is also for ios,i need something universal,so that i don't have write everything in native @DNax – Abhijith Apr 28 '20 at 12:18
 - 
                    What part are you struggling with? – Robin Dijkhof Aug 14 '20 at 23:57
 - 
                    1starting an activity from service, when screen is locked and or app is terminated /background – joyBlanks Aug 16 '20 at 09:40
 - 
                    I've developed a voip app. For ios we use callkit but for android we issue a notification for an incoming call. The user clicks on the notification launching the app. This paradigm then works whether the screen is turned off or locked. – spartygw Aug 17 '20 at 17:43
 - 
                    @spartygw what about popular video calling apps which show incoming call screen even if screen is locked – joyBlanks Aug 18 '20 at 14:19
 - 
                    @joyBlanks apple makes this easy with CallKit. Android less so. I know Samsung has their own thing but I haven't yet figured out a similar thing in Android that works across all flavors so we go with the notification paradigm I mentioned earlier. – spartygw Aug 18 '20 at 17:31
 
2 Answers
First things first. You need to learn about some concepts before delving into your solution. Actually there isn't an out of the box solution.
You need to use a couple of things together:
- Use push notifications to "wake up" your app:
https://pub.dev/packages/firebase_messaging
To start your app using push notifications refers to this post:
https://stackoverflow.com/a/48405551/4335775
 - Use CallKit (IOS) or ConnectionServices (Android) to show the upcoming call screen. By the day of this answer there are only a few packages to handle these things, here is one that can handle both platforms:
https://pub.dev/packages/flutter_callkeep 
If you want a completely different thing and need to run some background process, there are bunch whole of things you should know first. 
I suggest beginning here: https://flutter.dev/docs/development/packages-and-plugins/background-processes
 
Here is a usefull package to work with background processes that should be constantly running:
 https://pub.dev/packages/background_fetch
Currently there are two packages which provides integration for agora.io:
- https://pub.dev/packages/agora_rtc_engine (for Agora Real Time Communication, vídeo call included)
 - https://pub.dev/packages/agora_rtm for real-time messaging
 
I hope this can help you.
- 1,601
 - 12
 - 18
 
- 
                    
 - 
                    We have implemented the CallKeep package for Agora: https://github.com/Clinica-Mongolia/callkeep_agora – Mr White Jan 10 '22 at 10:14
 
You can try WorkManager plugin.
You can register an call back function to the os when the app is closed.
const myTask = "syncWithTheBackEnd";
void main() {
  Workmanager.initialize(callbackDispatcher);
  Workmanager.registerOneOffTask(
    "1",
    myTask, //This is the value that will be returned in the callbackDispatcher
    initialDelay: Duration(minutes: 5),
    constraints: WorkManagerConstraintConfig(
      requiresCharging: true,
      networkType: NetworkType.connected,
    ),
  );
  runApp(MyApp());
}
void callbackDispatcher() {
  Workmanager.executeTask((task) {
    switch (task) {
      case myTask:
        print("this method was called from native!");
        break;
      case Workmanager.iOSBackgroundTask:
        print("iOS background fetch delegate ran");
        break;
    }
    //Return true when the task executed successfully or not
    return Future.value(true);
  });
}
Maybe this can help you.
The complete article medium article
- 111
 - 5
 
- 
                    2looking for a fullscreen activity like incoming call screen when app is terminated/inbackground and screen may or mayn't be locked – joyBlanks Aug 14 '20 at 12:22