title: How can we get response from an app which was launched by another app?
body: <p>Please can someone help me how to get data from an app which was launched by my app.</p>
  
  <p>I am actually trying to integrate Google's Tez into my flutter app.</p>
  
  <p>I have successfully launched the app to make payments to the requested UPI. But, i want to get the response from Tez to my app.</p>
  
  <p>I've used url_launcher to launch Tez app in my flutter app.
  Unfortunately I was unable to listen to any response from Tez's app.
   I tried to use StreamSubscription but to no avail.</p>
  
  <p>I have posted the code for reference.</p>
  
  <p>code:</p>
  
  <pre><code>import 'dart:async';
  
  import 'dart:io';
  
  import 'package:flutter/material.dart';
  
  import 'package:url_launcher/url_launcher.dart';
  
  void main() {
    runApp(new MaterialApp(
      title: 'UPI Demo',
      home: new UpiDemo(),
    ));
  }
  
  class UpiDemo extends StatefulWidget {
    @override
    _UpiDemoState createState() =&gt; new _UpiDemoState();
  }
  
  class _UpiDemoState extends State&lt;UpiDemo&gt; {
    String payeeAddress;
    String payeeName;
    String transactionNote;
    String amount;
    String currencyUnit;
    HttpClientRequest request;
    HttpClientResponse response;
    List data = new List();
    Uri uri;
  
    StreamSubscription&lt;Map&lt;String, Object&gt;&gt; _paymentSubscription;
    Stream&lt;Object&gt; _payment;
    Stream&lt;Object&gt; _currentPayment;
  
    @override
    void initState() {
      super.initState();
      payeeAddress = "mobilenumber@upi";
      payeeName = "payeename";
      transactionNote = "Test for Deeplinking";
      amount = "1";
      currencyUnit = "INR";
  
      uri = Uri.parse("upi://pay?pa=" +
          payeeAddress +
          "&amp;pn=" +
          payeeName +
          "&amp;tn=" +
          transactionNote +
          "&amp;am=" +
          amount +
          "&amp;cu=" +
          currencyUnit);
    }
  
    @override
    void dispose() {
      super.dispose();
      request.close();
    }
    Future launchTez()async {
            try {
              if (await canLaunch(uri.toString())) {
  
              _paymentSubscription = await launch(uri.toString()).asStream().listen((var result){
                setState((){
                  _currentPayment = result;
                  print(_currentPayment);
                });
              });
              setState((){
                _currentPayment = _payment;
              });
  
              } else {
                throw 'Could not launch tez ';
              }
            } catch (exception) {
                       print(exception);
            }
        }
  
    @override
    Widget build(BuildContext context) {
      return new Scaffold(
        appBar: new AppBar(
          title: const Text('UPI Demo'),
        ),
        body: new Center(
          child: new RaisedButton(
            onPressed: (() {
              launchTez();
            }),
            child: new Text('Click to Pay Rs.1.0/-'),
          ),
        ),
      );
    }
  }
  </code></pre>
  
  <p>After launching the app I want to listen to the response as well like in this example from github <a href="https://github.com/ShahMalavS/UPI-DeepLinked" rel="nofollow noreferrer">here</a></p>
  
  <p>when the Tez app is launched the flutter app stops and on completing the transaction on Tez the flutter app resumes.</p>
  
  <p>Please can someone tell me how can i do this. The android example actually is listening to the response but I am unable to do it in flutter app.</p>