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 realize the function of delay Jump in Android activity

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces the relevant knowledge of "how to achieve delay jump function in Android activity". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to achieve delay jump function in Android activity" can help you solve the problem.

What is Activity?

Activity is an application component of Android that provides screens for interaction. Each Activity gets a window to draw its user interface, which can fill the screen or be smaller than the screen and float on top of other windows.

An application is usually composed of multiple Activity loosely related to each other, and an Activity in the application is generally designated as the main activity, that is, the Activity presented to the user when the application is launched for the first time. The method of setting Activity as the main activity, as shown in the following code, you need to add the following to the AndroidManifest file

.... ....

Of course, Activity can jump to each other to perform different operations. Whenever a new Activity starts, the old Activity stops, but the system retains the Activity in the stack, that is, the return stack. When the new Activity starts, the system will also push it to the return stack and get the focus of the user's operation. When the user completes the current Activity and presses the back button, the system pops it up and destroys it from the stack, and then replies to the previous Activity

When an Activity stops because a new Activity starts, the system notifies it of the change in this state through the Activity's lifecycle callback method. There may be several types of Activity due to state changes, and each callback provides an opportunity to perform specific actions corresponding to that state

Package club.zhuol.qqcopyexample;import androidx.appcompat.app.AppCompatActivity;import android.content.Intent;import android.os.Bundle;import android.os.Handler;import android.os.Message;import android.view.View;import android.view.WindowManager;import android.widget.TextView;public class CoverActivity extends AppCompatActivity {Handler handler; @ Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.activity_cover); myIntent (); init () } private void myIntent () {handler = new Handler () {@ Override public void handleMessage (Message msg) {if (msg.what! = 0) {/ / tv_skip.setText (msg.what + "enter APP after seconds");} else {click () };} private void init () {/ / full screen display getWindow () .setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); / / tv_skip = findViewById (R.id.tv_skip); / / textView.setText ("zhuoL"); new CountDown () .start () } private void click () {Intent intent = new Intent (CoverActivity.this, LoginActivity.class); startActivity (intent); finish ();} / / enter APP countdown class CountDown extends Thread {int count = 1; @ Override public void run () {try {while (count > = 0) {sleep (1000) Message message = new Message (); message.what = count; handler.sendMessage (message); count--;}} catch (InterruptedException e) {e.printStackTrace () This is the end of the content about "how to achieve the delay jump function in Android activity". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

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