Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the function of delay Jump in Android activity

Shulou Source: shulou.com Published: 2022-06-01 02:38:13 10月04日 Update

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.

Tags: User system application function screen method state knowledge change difference that is content stack industry activity utility loose countdown between that is to say Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei MySQL Apple Xiaomi MariaDB