handler延時tiaozhuan
package com.example.lenovo.mnyk01;
import android.content.Intent; import android.os.Handler; import android.os.Message; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private static final int FLAG = 123;
private Handler handler = new Handler(){ @Override public void handleMessage(Message msg) { super.handleMessage(msg);
if(msg.what==FLAG){ Intent intent = new Intent(MainActivity.this,ShowActivity.class); startActivity(intent); } } };
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
TextView txt = findViewById(R.id.text);
handler.sendEmptyMessageDelayed(FLAG,3000);
} }