Home > Mobile >  Android press the home button switch to the background, how to through the message again to switch t
Android press the home button switch to the background, how to through the message again to switch t

Time:11-16

I do an interface, press the home button switch to the background, a socket connection, when after you receive the socket to once again shows that the interface, how to write code,

The Internet to find some code, such as the following, but no response,

Intent Intent=new Intent (getApplicationContext (), MainActivity. Class);
Intent. SetFlags (intent. FLAG_ACTIVITY_REORDER_TO_FRONT);
StartActivity (intent);

CodePudding user response:

Intent. SetFlags (intent. FLAG_ACTIVITY_NEW_TASK); This FLAG

CodePudding user response:

App is not in the foreground, the first in the normal way to open, after a period of time (one or two seconds) if not open, and then try to use ActivityManager. MoveTaskToFront to open, if still can't open only to remind users,
Now the new version has a permission, whether to allow the background to open the application, as shown in the official document, each big manufacturer is different also, generally only the white list is the default state, their applications to open it is very normal,

CodePudding user response:

Ah, 1/f, positive solutions to add intent. The intent FLAG_ACTIVITY_NEW_TASK flag can be directly through the context. StartActivity (intext) jump
  • Related