hello i am new to android and i am having a webiste which i have converted into mobile APP just by using the **web view**
and what i want now is a function to put into the android so that i can find all the phine numbers in the website and make it clickable and dial that number on call .
function to call. i have already aded
<uses-permission android:name="android.permission.CALL_PHONE" />
and i have tried this in mainactivity.java
public static void linkifyTextViews(@NonNull TextView... textViews) {
for (TextView textView : textViews) {
Linkify.addLinks(textView, Linkify.WEB_URLS);
textView.setMovementMethod(LinkMovementMethod.getInstance());
}
}
EDITED
i have this is my mainactivity.java file
package com.business.i13bubbles;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.content.Intent;
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.view2);
WebSettings webSettings = MywebView.getSettings();
webSettings.setJavaScriptEnabled(true);
MywebView.loadUrl("http://www.13bubbles.com");
MywebView.setWebViewClient(new WebViewClient());
}
@Override
public void onBackPressed() {
if (MywebView.canGoBack()) {
MywebView.goBack();
} else {
super.onBackPressed();
}
}
public boolean shouldOverrideUrlLoading(WebView view2, String url) {
if (url.startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_DIAL,
url.parse(url));
startActivity(intent);
} else if (url.startsWith("http:") || url.startsWith("https:")) {
view2.loadUrl(url);
}
return true;
}
}
and i am getting this error
error: cannot find symbol method parse(String)
the id of my webview is view2
can you help me
EDIT 2
i think the error is here in this function
public boolean shouldOverrideUrlLoading(WebView view2, String url) {
if (url.startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_DIAL);
// Send phone number to intent as data
intent.setData(Uri.parse(url)); // ERROR LINE IS HERE FOR SURE
// Start the dialer app activity with number
startActivity(intent);
} else if (url.startsWith("http:") || url.startsWith("https:")) {
view2.loadUrl(url);
}
return true;
}
error: cannot find symbol variable Uri