This is my first attempt at Android coding. We have a responsive web site and I call myself writing the code for an android app so that people and simply click on the icon after downloading the app and hit our website. On the Simulator, the app works fine on the various test phone, but when I upload APK for distribution and someone downloads and tries to run it, it crashes even before the splash screen is seen. Can some one please look at my code and tell me what's wrong. It seems to only crash on Android software version 6.0 or higher. On the old phones and tablets it run fine. Here are copies of my "SplashScreenActivity.java, my MainActivity.java, and my AndroidManifest.xml from Android Studios version 3.2.1. Any help would be appreciated.
SplashScreenActivity.java
package com.wastefreemail.wfmconnect;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
public class SplashScreenActivity extends AppCompatActivity {
private int SLEEP_TIMER = 3;
@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.activity_splash_screen);
getSupportActionBar().hide();
LogoLauncher logoLauncher = new LogoLauncher();
logoLauncher.start();
}
private class LogoLauncher extends Thread{
public void run(){
try{
sleep(1000 * SLEEP_TIMER);
}catch(InterruptedException e){
e.printStackTrace();
}
Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class);
startActivity(intent);
SplashScreenActivity.this.finish();
}
}
}
MainActivit.java
package com.wastefreemail.wfmconnect;
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends Activity {
public WebView web1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
WebView web1 = (WebView)findViewById(R.id.web1);
WebSettings webSettings = web1.getSettings();
webSettings.setJavaScriptEnabled(true);
web1.loadUrl("https://www.wastefreemail.com");
web1.setWebViewClient(new WebViewClient());
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wastefreemail.wfmconnect">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
</activity>
<activity android:name=".SplashScreenActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>