I have converted my fully responsive website in to Android app using Android studio. I have also added one signal push notification. I have two questions.
Notification works fine but I want the notification to be opened in a separate window when I click it. what should be the code and where should I put those?
I want a page loading progress bar in my webview app (android studio).what should be the code and where should I put those?
My codes are as follows.
At mainactivity.java page
package com.example.rijvan.awebaddress;
import...
public class MainActivity extends AppCompatActivity {
public WebView mywebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
OneSignal.startInit(this)
.inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
.unsubscribeWhenNotificationsAreDisabled(true)
.init();
setContentView(R.layout.activity_main);
mywebView=(WebView)findViewById(R.id.webview);
WebSettings webSettings=mywebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mywebView.loadUrl("https://my web site/");
mywebView.setWebViewClient(new WebViewClient());
}
@Override
public void onBackPressed() {
if (mywebView.canGoBack()){
mywebView.goBack();
}else{
super.onBackPressed();
}
}
}
At activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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"
tools:layout_editor_absoluteY="81dp">
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp" />
</android.support.constraint.ConstraintLayout>
At AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.rijvan.awebaddress">
<uses-permission android:name="android.permission.INTERNET" />
<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">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I am really new in Android. Any help would be greatly appreciated.