java Android应用程序未打开黑屏问题
几天前,我制作了一个简单的安卓 webview应用程序,它运行良好,但现在问题发生了,一段时间后,应用程序没有打开,屏幕变黑,然后重新安装,它是正确的,一段时间它是正确的,然后同样的问题就来了,如果有人帮助,那将是非常好的
Mi redmi note 6 Pro Android V 9 PIE
源代码
舱单。xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
package="com.musicwala.djaman" >
<uses-permission 安卓:name="安卓.permission.INTERNET" />
<uses-permission 安卓:name="安卓.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission 安卓:name="安卓.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission 安卓:name="安卓.permission.ACCESS_NETWORK_STATE"/>
<application
安卓:allowBackup="true"
安卓:usesCleartextTraffic="true"
安卓:icon="@drawable/main"
安卓:label="@string/app_name"
安卓:theme="@style/AppTheme"
安卓:resizeableActivity="true">
<activity
安卓:name=".MainActivity"
安卓:label="@string/app_name"
安卓:theme="@安卓:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action 安卓:name="安卓.intent.action.MAIN" />
<category 安卓:name="安卓.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
安卓:name=".web_main">
</activity>
<activity
安卓:name=".setting">
</activity>
<activity
安卓:name=".about"
安卓:theme="@安卓:style/Theme.NoTitleBar.Fullscreen">
</activity>
<activity
安卓:name=".update">
</activity>
<activity
安卓:name=".download">
</activity>
<activity 安卓:name=".play_ui"
安卓:theme="@style/Theme.AppCompat.Light">
</activity>
</application>
</manifest>
建造。梯度
apply plugin: 'com.安卓.application'
安卓 {
compileSdkVersion 29
defaultConfig {
applicationId "com.musicwala.djaman"
minSdkVersion 14
targetSdkVersion 29
versionCode 3
versionName "3.1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-安卓.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile ('安卓.arch.core:runtime:+') {
force = true
}
compile 'com.安卓.support:appcompat-v7:27.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
主要活动。java
package com.musicwala.djaman;
import 安卓.app.*;
import 安卓.os.*;
import 安卓.view.Window;
import 安卓.widget.AbsoluteLayout.LayoutParams;
import 安卓.view.WindowManager;
import 安卓.content.Intent;
import 安卓.util.Log;
import 安卓.net.NetworkInfo;
import 安卓.net.ConnectivityManager;
import 安卓.content.Context;
import 安卓.content.DialogInterface;
import 安卓.provider.Settings;
import 安卓.widget.Toast;
public class MainActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//requestWindowFeature(Window.FEATURE_NO_TITLE);
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
// WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
if(isNetworkConnectionAvailable() == true)
{
final Handler h = new Handler();
h.postDelayed(new Runnable() {
@Override
public void run() {
//Do something after 1s
Intent intent = new Intent(MainActivity.this,web_main.class);
startActivity(intent);
finish();
}
}, 1000);
}
}
public void checkNetworkConnection(){
AlertDialog.Builder builder =new AlertDialog.Builder(MainActivity.this);
builder.setTitle("No internet Connection");
builder.setMessage("Please turn on internet connection to continue!");
builder.setPositiveButton("Turn On", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
MainActivity.this.startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
}
}).show();
builder.setNegativeButton("Exit", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finishAffinity();
}
}).show();
AlertDialog alertDialog = builder.create();
alertDialog.show();
}
public boolean isNetworkConnectionAvailable(){
ConnectivityManager cm =
(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null &&
activeNetwork.isConnected();
if(isConnected) {
Log.d("Network", "Connected");
return true;
}
else{
checkNetworkConnection();
Log.d("Network","Not Connected");
return false;
}
}
}
在我的另一台设备中工作正常
Android v8.0 Oreo
# 1 楼答案
清除手机缓存、数据并重新启动手机