1
Show a picture if the device is not connected to the internet
Good afternoon gentlemen I’m new in Android programming, I’m using Android Studio
Next I am developing an app that simply calls a webVier, which directs to my site, and I would like to know how to make if the mobile phone is not connected to the internet instead of calling the webvier it opens an image. my code on the manifest
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<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"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
and I’m using it here on Main activy
import androidx.appcompat.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 delivery;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
leve=findViewById(R.id.site);
leve.getSettings().setJavaScriptEnabled(true);
leve.setFocusable(true);
leve.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
leve.getSettings().setAppCacheEnabled(true);
leve.getSettings().setDomStorageEnabled(true);
leve.setWebViewClient(new WebViewClient());
leve.loadUrl("https://meusite.com.br");
}
}
I hope I’ve been clear Thank you for now
This answers your question? How to identify Internet connectivity status change to execute a connection method?
– Piovezan