Problem in a single instance of an action in Android

I have two classes. Aand B. Alaunches B. Both work on the screen, and both are visible. Say what is now Bvisible.

By pressing a special key, I want to bring it Aforward and make it active. The problem that I am facing is that when I press a special key, another instance is launched Aand the new instance is brought to the fore.

But I want the original to Acome forward. I want to make this change in the structure layer, not in the application, using the theme singleInstancein the launchMode file in the file AndroidManifest.

+2
source share
2 answers

From the Google Android documentation:

Defining trigger modes

The launch mode allows you to determine how a new example of activity is related to the current task. You can define different startup modes in two ways: using the manifest file

When you declare an action in your manifest file, you can specify how the activity should be associated with tasks when it starts. Using Intent Flags

When you call startActivity (), you can include a flag in the intent, declaring how (or) a new activity should be associated with the current task.

So, you can start your activity A with Activity B using Intent and pass the flag FLAG_ACTIVITY_SINGLE_TOP .

+1
source

manfiest ?

, , .

0

Source: https://habr.com/ru/post/1763591/


All Articles