2

I made a simple app of android webview a few days ago and it runs fine but the problem is happening now that after some time the app is not open, that screen is going black and reinstall After doing it, it is going right, for some time it is going right, then the same problem is coming, if someone helps, it will be very kind.

Mi redmi note 6 Pro Android V 9 PIE

Source Code

manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.musicwala.djaman" >
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <application
        android:allowBackup="true"
        android:usesCleartextTraffic="true"
        android:icon="@drawable/main"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        android:resizeableActivity="true">
        <activity

            android:name=".MainActivity"
            android:label="@string/app_name" 
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".web_main">
        </activity>
        <activity
            android:name=".setting">
        </activity>
        <activity
            android:name=".about"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
        </activity>
        <activity
            android:name=".update">

        </activity>
        <activity
            android:name=".download">

        </activity>
        <activity android:name=".play_ui"
            android:theme="@style/Theme.AppCompat.Light">

        </activity>
    </application>

</manifest>

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29

    defaultConfig {
        applicationId "com.musicwala.djaman"
        minSdkVersion 14
        targetSdkVersion 29
        versionCode 3
        versionName "3.1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile ('android.arch.core:runtime:+') {
       force = true
}   

    compile 'com.android.support:appcompat-v7:27.+'
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

MainActivity.java

package com.musicwala.djaman;

import android.app.*;
import android.os.*;
import android.view.Window;
import android.widget.AbsoluteLayout.LayoutParams;
import android.view.WindowManager;
import android.content.Intent;
import android.util.Log;
import android.net.NetworkInfo;
import android.net.ConnectivityManager;
import android.content.Context;
import android.content.DialogInterface;
import android.provider.Settings;
import android.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;
        }
    }
    
    
}

And is working fine in my other device

Android v8.0 Oreo

Community
  • 1
  • 1
  • 1
    `compile` is deprecated. Use `implementation` while declaring the `build.gradle` dependencies. See this link : https://stackoverflow.com/a/44493379/9167710 – cgb_pandey May 29 '20 at 09:16
  • Will doing this fix the problem? –  May 30 '20 at 04:07
  • 1
    I'm not so sure about that. But, if you have problems only on the newer version of the android then there might be chance that you are using some deprecated methods. Check the logs for possible warnings or errors. Also, it is not recommended to append `+` after the version number while declaring dependencies in the `build.gradle` file. Try to specify the exact version. – cgb_pandey May 30 '20 at 05:51

1 Answers1

1

Clear your phone cache ,data and restart your phone!

Dj aman motihari
  • 83
  • 1
  • 1
  • 11