Enable animation for android apps
For example, if A. java enables an animation, it then enters B. java.
1. A. java
Protected void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
Log. I ("START Animation", "Start Animation ");
// Remove the title
RequestWindowFeature (Window. FEATURE_NO_TITLE );
// Set full screen
GetWindow (). setFlags (WindowManager. LayoutParams. FLAG_FULLSCREEN,
WindowManager. LayoutParams. FLAG_FULLSCREEN );
SetContentView (R. layout. activity_start );
// Specifies the 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 + returned data", 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 );
}
// Explanation
1. new Handler (). postDelayed (new Runnable (){...}
Delay intent jump
2. startActivityForResult (intent, 10 );
Parameter: (Intent intent, Int requestCode)
RequestCode is used for later destruction.
3. onActivityResult (int requestCode, int resultCode, Intent data ){
ResultCode: indicates the data returned by B. java. When B. java is started, data is sent.
A. java destroys data by itself.
4. setResult (20 );
B. Data Set in java returned to A. java. A. java destroys the data by itself.