TheFinestArtist / FinestWebView-Android

Beautiful and customizable Android Activity that shows web pages within an app.
https://finestwebview.web.app
2.32k stars 531 forks source link

How can I close click pragmatically ? #125

Open raj9686 opened 7 years ago

raj9686 commented 7 years ago

https://stackoverflow.com/questions/45208977/how-can-i-close-pragmatically-finestwebview

ismdcf commented 7 years ago

@raj9686 did you figure it out

atebsy commented 6 years ago

has anyone figured this out yet?

atebsy commented 6 years ago

@raj9686 @ismdcf I found a way to work around this: Add the finestwebview activity to the manifest with the attribute noHistory set to true like this <activity android:name="com.thefinestartist.finestwebview.FinestWebViewActivity" android:configChanges="keyboardHidden|orientation|screenSize" android:screenOrientation="sensor" android:theme="@style/FinestWebViewTheme.Light" android:noHistory="true"/> And then just start the activity you want to show after the finestwebview is close. I hope it helps......

shimiuh commented 6 years ago

@Override public void onActivityCreated(Activity activity, Bundle bundle) { if (activity instanceof FinestWebViewActivity) { mCurrentWebViewActivity = activity; } } and

final FinestWebView.Builder builder = new FinestWebView.Builder(getActivity());
builder.setWebViewListener(new WebViewListener() {
    @Override
    public void onPageStarted(String url) {
        super.onPageStarted(url);

        if (url.startsWith(Constants.THANK_YOU_PAGE)) {
            Activity webViewActivity = AppController.getInstance().getCurrentWebViewActivity();
            if (webViewActivity != null) {
                webViewActivity.finish();
            }
        }
    }
});
builder.show(url);
shanecontinued commented 6 years ago

@shimiuh can you explain this code?

gintechsystems commented 4 years ago

I implemented some code to allow us to programmatically close the activity. You can do Builder.close()

Kotlin Example:

val webviewBuilder = FinestWebView.Builder(this)
webviewBuilder.setWebViewListener(object : WebViewListener() {
            override fun onPageFinished(url: String?) {
                Handler().postDelayed({
                    webviewBuilder.close()
                }, 5000)
            }
})

implementation 'com.github.gintechsystems:FinestWebView-Android:1.2.7'