Home > Mobile >  After Android7.0 boot animation will play a video screen
After Android7.0 boot animation will play a video screen

Time:11-03

Ever great god add boot advertising, is after the first boot boot animation that the launcher before the start of broadcast a video advertisement, I have add success, but through the video videoView play under the res, including custom activity by the following code in the video broadcast
 
//the specified video file
String path="android. Resource://" + getPackageName () + "/" + R.r aw. The advert.
//String path=Environment. External.getexternalstoragedirectory () getPath () + "/temp. Mp4";
The Log. I (" tag ", "path=" + path);
if (! TextUtils. IsEmpty (path)) {
VideoView. SetVideoPath (path);
VideoView. SetVideoURI (Uri. Parse (path));
VideoView. RequestFocus ();
VideoView. Start ();
}

VideoView. SetOnPreparedListener (new MediaPlayer. OnPreparedListener () {
@ Override
Public void onPrepared (MediaPlayer mp) {
Mp. SetOnInfoListener (new MediaPlayer. OnInfoListener () {
@ Override
Public Boolean onInfo (MediaPlayer mp, int what, int extra) {
Log. I (" tag ", "I=" + I);
If (I==MediaPlayer. MEDIA_INFO_VIDEO_RENDERING_START) {
.//videoView. SetBackgroundResource (R.d rawable shutdown_bg);
VideoView. SetBackgroundColor (Color. TRANSPARENT);
}
return false;
}
});
}
});

VideoView. SetOnCompletionListener (new MediaPlayer. OnCompletionListener () {
@ Override
Public void onCompletion MediaPlayer (mp) {
Log. I (" tag ", "persist. Sys. Videoad. Finished=" + SystemProperties. Get (" persist. Sys. Videoad. Finished ", "0"));
If (" 0 ". The equals (SystemProperties. Get (persist. Sys. Videoad. "finished", "0"))) {
SystemProperties. Set (persist. Sys. Videoad. "finished", "1");
}
finish();
//mp. The start ();
//mp. SetLooping (true);

}
});

After AndroidManagerService. Java startHomeActivityLocked method to implement jump
 
If (" 0 ". The equals (SystemProperties. Get (persist. Sys. Videoad. "finished", "0"))) {
if(! MVideoAdvertActivityRunning) {
Intent videoAdvertActivity=new Intent ();
VideoAdvertActivity. AddFlags (Intent. FLAG_ACTIVITY_NEW_TASK);
VideoAdvertActivity. SetClassName (" com. Android. Systemui ", "com. Android. Systemui. VideoAdvertActivity");
MContext. StartActivity (videoAdvertActivity);
MVideoAdvertActivityRunning=true;
}
return false;
}


Above modification can be implemented in the launcher before the start of a video, but before the play will have a black screen, originally in front of the boot flash after will enter the launcher has the black screen, but compared to black screen time is shorter, can you tell me how to optimize?
  • Related