我正在编写一个Android应用程序,并且有一个视频作为启动屏幕,但是每当我在平板电脑上打开该应用程序时,在视频播放期间屏幕都会变黑。初始屏幕在电话和虚拟设备(电话和平板电脑模拟器)上都可以正常工作,但是在任何物理平板电脑上,只能看到黑屏。
我已经为初始屏幕提供了清单文件和Java文件。难道我做错了什么?视频初始屏幕与常规静态照片初始屏幕是否有所不同?
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myPackage">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:hardwareAccelerated="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".SplashScreen"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Light">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".HomeActivity"
android:label="@string/title_activity_home"
android:theme="@style/AppTheme.NoActionBar"
android:configChanges="orientation"
android:screenOrientation="portrait"/>
<activity
android:name=".InfoActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:label="@string/title_activity_info"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".InfoActivity" />
</activity>
<activity
android:name=".FixConditions"
android:label=""
android:configChanges="orientation"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".InfoActivity" />
</activity>
<activity
android:name=".WebViewSignUp"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:label=""
android:theme="@style/AppTheme.NoActionBar"></activity>
</application>
SplashScreen.java
public class SplashScreen extends AppCompatActivity {
VideoView videoView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_splash_screen);
getSupportActionBar().hide();
videoView = (VideoView)findViewById(R.id.videoView);
Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.into);
videoView.setVideoURI(video);
videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mediaPlayer) {
if (isFinishing())
return;
startActivity(new Intent(SplashScreen.this, HomeActivity.class));
finish();
}
});
videoView.start();
}
}
答案 0 :(得分:0)
这是视频尺寸的问题。我不得不将宽度更改为800,将高度更改为1280。
答案 1 :(得分:0)
android:hardwareAccelerated="false"
到
android:hardwareAccelerated="true"