Skip to main content

1. activity_main.xml

Inside the activity_main.xml.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:background="#182b5c">

<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
tools:layout_editor_absoluteX="146dp"
tools:layout_editor_absoluteY="207dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
SplashScreen.Java
package com.example.kcau;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

public class SplashScreen extends AppCompatActivity {
private int SLEEP_TIMER = 4;
@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(SplashScreen.this, MainActivity.class );
startActivity(intent);
SplashScreen.this.finish();
}
}
}
activity_splash_screen.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SplashScreen"
android:background="#182b5c">

<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/kca_logo" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Developed by: Samuel Kioko, IT Club Town Campus"
android:textAlignment="center"
android:textColor="#ffffff"
android:textSize="16dp"
android:textStyle="italic"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.979" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="KCA UNIVERSITY"
android:textAlignment="center"
android:textColor="#FFD700"
android:textSize="40dp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Advancing Knowledge, Driving Change"
android:textColor="#FFD700"
android:textSize="20dp"

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/textView3"
app:layout_constraintVertical_bias="0.119" />

</androidx.constraintlayout.widget.ConstraintLayout>

colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="dark_blue">#182b5c</color>
<color name="gold">#FFD700</color>
</resources>
Androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.kcau">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:allowBackup="true"
android:icon="@drawable/kca_logo"
android:label="KCA UNIVERSITY"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.KCAU">
<activity android:name=".SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity">

</activity>
</application>

</manifest>


main_activity.java
package com.example.kcau;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.webkit.DownloadListener;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends AppCompatActivity {
private WebView myWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myWebView=(WebView)findViewById(R.id.webView);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.loadUrl("https://www.kca.ac.ke/");
myWebView.setWebViewClient(new WebViewClient());

myWebView.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
}

@Override
public void onBackPressed() {
if(myWebView.canGoBack()){
myWebView.goBack();
}else {
super.onBackPressed();
}
}
}

Comments

Popular posts from this blog

HOW TO SOLVE WINDOWS 10 BLACK SCREEN WITH CURSOR PROBLEM

Perhaps you have done some updates or installed new software on your windows computer and then all you can see after logging in is a black screen with a white mouse cursor. Something more like this.. This could have happened due to some malware or some system update that is conflicting with your system settings. There are various methods you can solve this; - Manually correcting the user shell - Troubleshooting from advanced start-up option. Method 1: Manually correct the user shell 1. Open task manager while on the black screen. Press the keyboard combination Ctrl+Alt+Del or right-click at the bottom part of your black screen then move three times with your upper arrow key and press enter to open task manager. 2. A task manager window will show. Go to File >> Run new task >> type in regedit >> check the checkbox (create this task with administrator privileges) >> then click OK. 3. Double click / Expand the HKEY_LOCAL_MACHINE folder. 4. Double click / Expand ...