Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of being covered by applied snapshots after AndroidActivity is opened

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

What this article shares to you is about how to solve the problem of being covered by the snapshot of the application after opening the AndroidActivity. The editor thinks it is very practical, so I share it with you for study. I hope you can get something after reading this article.

When adding a desktop shortcut to the company's UnionPay QR code function, I encountered a headache as follows:

Test to switch back and forth between the four tab of the app main interface, then click the home key, click the desktop shortcut, and it is probable that the UnionPay QR code interface is obscured by the main interface snapshot.

Phenomenon (after the interface of UnionPay QR code is obscured by the snapshot of the main interface):

1. Go to the nearest taskbar and find that the snapshot in the recent taskbar is also the Activity of the main interface, which is also wrong.

two。 Looking at the task stack information through adb, it is found that the task stack information is normal, and the UnionPay QR code interface is indeed on HomeActivity, but it is obscured by the application snapshot.

3. Page click event

In response to the click event on the UnionPay QR code page.

4. The page goes to the background and opens again

OnStop- > onRestart- > onStart- > onResume UnionPay QR code page recovery.

Why is there a snapshot?

In the preparatory phase of Activity startup, PMS is used to confirm the Activity that needs to be started, and verify the intent and permissions. At the same time, configure task according to launcheMode and flag. At this time, you can make a transition by loading snapshots (preview window) to improve user experience.

When the home key is pressed, framework saves a snapshot of the application, which can be obtained through taskId. When the application enters the foreground from the background, the snapshot will be displayed first, and then the lifecycle method of the current Activity will be executed. When ActivityStack executes startActivityLocked, it formally enters the display process of starting window through the showStartingWindow method of ActivityRecord.

Of course, the way to jump to UnionPay QR code is to call the basic encapsulation method.

The cause of the problem:

Snapshot destruction failed. The entry of the application to the foreground triggered the drawing of the snapshot, but failed to destroy the snapshot.

ActivityStack.java

The final modification scheme:

The jump method that jumps to the UnionPay QR code interface is delayed by 500ms to ensure that the HomeActivity components of the main interface are initialized, thus successfully destroying the snapshot.

The above is how to solve the problem of being covered by application snapshots after AndroidActivity is opened. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report