简体   繁体   中英

How to exit from android app after start a new activity?

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?

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

finish();

command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM