For example: A.java to start the animation, and then into the B.java
1.a.java
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
LOG.I ("Start animation", "Start animation");
Remove title
Requestwindowfeature (Window.feature_no_title);
Set Full Screen
GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Setcontentview (R.layout.activity_start);
Turn on animation duration
New Handler (). postdelayed (New Runnable () {
@Override
public void Run () {
TODO auto-generated Method Stub
Intent intent=new Intent (Startactivity.this,
Mainactivity.class);
Startactivityforresult (intent,10);
}
}, 1000*2);
}
@Override
protected void Onactivityresult (int requestcode, int resultcode, Intent data) {
TODO auto-generated Method Stub
LOG.I ("startactivity+ has data return", requestcode+ "");
Super.onactivityresult (Requestcode, ResultCode, data);
if (resultcode==20) {
Finish ();
}
}
2.b.java
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Set the response so that startactivity () closes itself
Setresult (20);
Setcontentview (R.layout.activity_main);
}
Explain
1.new Handler (). postdelayed (New Runnable () {... }
Delay Intent Jump
2.startActivityForResult (intent,10);
Parameters:(Intent Intent, Int requestcode)
Requestcode is used for later destruction.
3. Onactivityresult (int requestcode, int resultcode, Intent data) {
ResultCode: Represents the data returned by B.java, which is sent when the B.java is started.
A.java according to the data, destroy themselves.
4.Setresult (20);
The data that is set in B.java is returned to A.java, andA.java is destroyed according to the data itself.
Enable animation for Android apps