Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoLink in XML? #175

Open
jesichakirkland opened this issue Jul 2, 2018 · 10 comments
Open

autoLink in XML? #175

jesichakirkland opened this issue Jul 2, 2018 · 10 comments

Comments

@jesichakirkland
Copy link

Hi,
so is there any equivalent to android:autoLink in RichEditor?
or anyone know how to open new webview when a link is clicked?
Thankyou

@nikitrivedii
Copy link

Were you able to resolve this issue ?

@jesichakirkland
Copy link
Author

no i didn't. i just set the text to be copyable in android so that the user can copy the link by themself...

@nikitrivedii
Copy link

` @OverRide
public boolean shouldOverrideUrlLoading(WebView view, String url) {

        String decode;
        try {
                **url = view.getHitTestResult().getExtra();**
            decode = URLDecoder.decode(url, AppConstants.ENCRYPTION_CHAR_FORMAT_UTF8);
        } catch (UnsupportedEncodingException e) {
            // No handling
            return false;
        }

        if (TextUtils.indexOf(url, CALLBACK_SCHEME) == 0) {
            callback(decode);
            return true;
        } else if (TextUtils.indexOf(url, STATE_SCHEME) == 0) {
            stateCheck(decode);
            return true;
        }

        if (url.startsWith("http:https://") || url.startsWith("https://")) {
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            context.startActivity(i);
            return true;
        }

        if (url.startsWith("file:https:///android_asset/")) {
            String newUrl = url.substring("file:https:///android_asset/".length());
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse("http:https://" + newUrl));
            context.startActivity(i);
            return true;
        }

        return super.shouldOverrideUrlLoading(view, url);
    }
}`

using this i was able to click the url and open it in webview

@jesichakirkland
Copy link
Author

thankyou for the info, i will try it soon i have the time 😄

@AkashAndi
Copy link

Where to write this code ?
do I need to add this library as a module and change its override method ?

@AkashAndi
Copy link

I have implemented above tings but it didn't work!

@Ann-Mobiz
Copy link

@nikitrivedii I am also facing the same issue. Please could you tell where to write this code?

@fukemy
Copy link

fukemy commented Nov 7, 2021

always trigger shouldOverrideUrlLoading(WebView view, WebResourceRequest request)
not shouldOverrideUrlLoading(WebView view, String url), so i can not get url

@fukemy
Copy link

fukemy commented Nov 7, 2021

the request.url always return :https://re-state

@fukemy
Copy link

fukemy commented Nov 7, 2021

Ảnh chụp Màn hình 2021-11-07 lúc 19 23 14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants