0

I'm developing 2 android application, first with Xamarin.Forms (A) and the other one with native android (B).

I have a button in A app which open B app. Code:

PackageManager pm = Application.Context.PackageManager;

            if (IsAppInstalled(packageName))
            {
                Intent intent = pm.GetLaunchIntentForPackage(packageName);

                if (intent != null)
                {
                    intent.SetFlags(ActivityFlags.NewTask);
                    Application.Context.StartActivity(intent);
                }
            }

In B app i have to collect some datas then pass datas to A app.

Intent browserIntent = App.AppContext.getPackageManager().getLaunchIntentForPackage("xxx");
            browserIntent.setAction(Intent.ACTION_VIEW);
            browserIntent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
            browserIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

            browserIntent.putExtra("xx","");
            browserIntent.putExtra("xz","2");        

            startActivity(browserIntent);

How can i exit from B app after go back to A app?

  • `...exit from B app after go back to A app...` You have, once you start the "A" activity from app "B", app "B" is now in the background and app "A" is the foreground app. If you are trying to programmatically remove app "B" from the task manager/list, you can not. – SushiHangover Nov 16 '20 at 15:21
  • Thanks for your answer. You pointed out that remove app from task list is not possible. – xpowerfullx Nov 17 '20 at 02:18

1 Answers1

-1

If I understood correctly, you'd like to close the activity, this can be done by using

finish();

command.

bvk256
  • 1,837
  • 3
  • 20
  • 38