Sometimes you need to run the activity in the background. The specific implementation method is as follows:
In androidmanifest. XML, add:
Android: theme = "@ style/backgroundonly"
Android: configchanges = "orientation | keyboardhidden"
As shown in the following figure:
<Activity Android: Name = "activityname"
Android: Label = "@ string/app_name"
Android: theme = "@ style/backgroundonly"
Android: configchanges = "orientation | keyboardhidden">
The content of style. XML is as follows:
<Resources>
<Style name = "backgroundonly">
<Item name = "Android: windowbackground"> @ null </item>
<Item name = "Android: windowcontentoverlay"> @ null </item>
<Item name = "Android: windowanimationstyle"> @ null </item>
<Item name = "Android: windownotitle"> true </item>
<! -- <Item name = "Android: windownodisplay"> true </item>
--> <Item name = "Android: javaswisfloating"> true </item>
</Style>
</Resources>
In this way, the activity runs in the background. When you finish your task, you can end it with finish.