I have been getting an error while creating a WebView in android studio, the error says the API is deprecated. I'm adding the code of my file. I think it would be easy to find, but I have no experience in android so I'm not able to find the error.
I have read about the updates of the android / java but could not find this
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
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.view2);
WebSettings webSettings = MywebView.getSettings();
webSettings.setJavaScriptEnabled(true);
MywebView.loadUrl("http://www.ynaps.com");
MywebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.contains("tel:")) {
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(url));
startActivity(intent);
return true;
}else{
return false;
}
}
});
}
@Override
public void onBackPressed() {
if (MywebView.canGoBack()) {
MywebView.goBack();
} else {
super.onBackPressed();
}
}
}
I should not get this error:
E:\APP\pro\sdddd-
dunia\app\src\main\java\com\business\ynaps_app\MainActivity.java:
uses or overrides a deprecated API.
Recompile with -Xlint:deprecation for details.