How to Implement No Internet Dialog in Android Studio | NoInternetDialog | Android Coding

Поділитися
Вставка
  • Опубліковано 19 вер 2024
  • No Internet Dialog Tutorial : In This Video, You Will Learn How to Integrate Alert Dialog For No Internet in Android Studio.
    All File :
    1) activity_main.xml 2) MainActivity.java
    Table Of Content :
    0:23 - Project Creation
    0:44 - XML Code
    1:15 - Java Code
    12:07 - Output
    Presented By : Android Coding
    Background Music By : NoCopyrightSounds
    Download PNG Link :
    drive.google.c...
    Download Apk Link :
    drive.google.c...
    All My App Links :
    1) QR Scanner App : bit.ly/ScannerA...
    2) Colors Code App : bit.ly/ColorsCode
    3) Age Calculator App : bit.ly/AndroidA...
    Enjoy & Stay Connected With Us!
    ► Subscribe To Android Coding : bit.ly/UA-cam-...
    ► Like Us On Facebook : bit.ly/Facebook...
    ► Follow Us On Instagram : bit.ly/Instagra...
    ► Follow Us On Twitter : bit.ly/Twitter-...
    #NoInternetDialog #AndroidTutorial #12H1r

КОМЕНТАРІ • 49

  • @foodiemonster9066
    @foodiemonster9066 Рік тому +1

    Thanks for sharing

  • @mohammadrezai2875
    @mohammadrezai2875 2 роки тому +1

    ok very good

  • @hosseinniazi7599
    @hosseinniazi7599 4 роки тому +1

    your videos are perfect , please continue recording

  • @shankarlekule
    @shankarlekule 3 роки тому +1

    Very nice bro

  • @TechDiet
    @TechDiet 3 роки тому

    Good

  • @prosantoit
    @prosantoit 4 роки тому +1

    Thank for your nice tutorial...

  • @k1z1eMe01
    @k1z1eMe01 4 роки тому +1

    Thank you for this tutorial, it helps me.

  • @ActressandModels
    @ActressandModels 3 роки тому +1

    thank you really help

  • @ankonsarkar9657
    @ankonsarkar9657 4 роки тому +1

    Wow that's great..

  • @vasamnamitha
    @vasamnamitha 2 роки тому +2

    Bro , make a video on Navigation Drawer wihch contains share, rate and contact options like insta, fb, and twitter . Please make this video. In my app I'm unable to add these .

  • @UtkuAydn99
    @UtkuAydn99 3 роки тому +2

    Try again button have a problem when get the conenction and use the button ,dialog never let go then you just need to write these
    public void onClick(View v) {
    recreate();
    dialog.cancel();
    // this is the fix

  • @abelalemuberhe2600
    @abelalemuberhe2600 3 роки тому +1

    Thank you for this tutorial but I got one problem when I touch one thing on the app, it will redirect to the default browser. What can i do to use the app without redirecting??

  • @freshtechtips
    @freshtechtips 4 роки тому

    ​ @Android Coding please but how to implement this code in fragment ( i watch your last video bottom navigation ) and i want add this to fragment how?
    // no internet custompage initialize connectivity manager
    ConnectivityManager connectivityManager = (ConnectivityManager)
    getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
    //Get activite network info
    NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
    // check network status
    if (networkInfo == null || !networkInfo.isConnected() || !networkInfo.isAvailable()) {
    //When internet is inactive
    //InitaLize Dialog
    Dialog dialog = new Dialog(this);
    //set content view
    dialog.setContentView(R.layout.alert_dialog);
    //set outside touch
    dialog.setCanceledOnTouchOutside(false);
    //set dialog width and height
    dialog.getWindow().setLayout(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
    //set transparent background
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    //set animation
    dialog.getWindow().getAttributes().windowAnimations =
    android.R.style.Animation_Dialog;
    //Intitialize dialog variable
    Button btTryAgain = dialog.findViewById(R.id.bt_try_again);
    // Perform onCLick listener
    btTryAgain.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
    //Call Recreate methode
    recreate();
    }
    });
    //Show Dialog
    dialog.show();
    } else {
    //When Internet is activate
    //Loadurl in webview
    webview.loadUrl("www.egtshop.com");
    }

  • @kushlendr1
    @kushlendr1 4 роки тому +3

    Is this check network connection continuously. I mean, if the app is ON and suddenly the internet is gone then?

    • @AndroidCoding
      @AndroidCoding  4 роки тому

      You can use work manager to perform this action.

    • @laiba426
      @laiba426 3 роки тому +1

      @@AndroidCoding how to use please tell

  • @k.venkatanagakruthik4597
    @k.venkatanagakruthik4597 4 роки тому +1

    If network got disconnected dialog should appear

  • @spotonsdigiwaiter5822
    @spotonsdigiwaiter5822 3 роки тому +1

    Bro you are not showing the creation of button id so i dont know how to solve this. other codes are working perfectly.

  • @huzaifaabbas94
    @huzaifaabbas94 4 роки тому

    dialog.setContentView(R.layout.alert_dialog);
    error on alert_dialog
    when i click suggestion it says to create new file. when making new file it says file already exists.
    no file renaming helped

  • @cyberkingcapitals9839
    @cyberkingcapitals9839 4 роки тому +1

    This same dialog box I want to add in onReceivedError how can I do this

    • @AndroidCoding
      @AndroidCoding  4 роки тому

      it is simple. Write the same code inside your method where you want to put.

    • @freshtechtips
      @freshtechtips 4 роки тому

      ​@@AndroidCoding please but how to implement this code in fragment ( i watch your last video bottom navigation ) and i want add this to fragment how?
      // no internet custompage initialize connectivity manager
      ConnectivityManager connectivityManager = (ConnectivityManager)
      getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
      //Get activite network info
      NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
      // check network status
      if (networkInfo == null || !networkInfo.isConnected() || !networkInfo.isAvailable()) {
      //When internet is inactive
      //InitaLize Dialog
      Dialog dialog = new Dialog(this);
      //set content view
      dialog.setContentView(R.layout.alert_dialog);
      //set outside touch
      dialog.setCanceledOnTouchOutside(false);
      //set dialog width and height
      dialog.getWindow().setLayout(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
      //set transparent background
      dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
      //set animation
      dialog.getWindow().getAttributes().windowAnimations =
      android.R.style.Animation_Dialog;
      //Intitialize dialog variable
      Button btTryAgain = dialog.findViewById(R.id.bt_try_again);
      // Perform onCLick listener
      btTryAgain.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
      //Call Recreate methode
      recreate();
      }
      });
      //Show Dialog
      dialog.show();
      } else {
      //When Internet is activate
      //Loadurl in webview
      webview.loadUrl("www.egtshop.com");
      }

  • @kuchbhi2421
    @kuchbhi2421 4 роки тому

    if we need to go mainactivity so what can we do in }else{
    }

  • @agamurat3019
    @agamurat3019 3 роки тому

    Where is recreate() method. what does it do?

  • @vishalkumavat6755
    @vishalkumavat6755 3 роки тому

    where is recreate function in this tutorial??

  • @amitghosh3938
    @amitghosh3938 4 роки тому

    network info is deprecated do you have any alternative to this?

  • @neelanjanbhattacharya877
    @neelanjanbhattacharya877 4 роки тому +2

    NetworkInfo has been deprecated by API 29

    • @AndroidCoding
      @AndroidCoding  4 роки тому

      Try this :
      ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); if (activeNetwork != null) { // connected to the internet if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) { // connected to wifi } else if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) { // connected to mobile data } } else { // not connected to the internet }

    •  4 роки тому

      @@AndroidCoding doesn't work..:(

  • @k.venkatanagakruthik4597
    @k.venkatanagakruthik4597 4 роки тому

    Bro how to implement continuously throug out the app

  • @e-sportshort
    @e-sportshort 4 роки тому +1

    Toutorial admob ads native thx android coding

    • @AndroidCoding
      @AndroidCoding  4 роки тому

      Welcome. Keep supporting android coding

  • @abdullahtrkmn
    @abdullahtrkmn 4 роки тому

    i made but not working

  • @saisreekarsesham5912
    @saisreekarsesham5912 4 роки тому

    Hello I want to disable that dialog as soon as I turn on the internet can u tell me how?

  • @frontendprodesigner4299
    @frontendprodesigner4299 4 роки тому

    plz in kotlin thank u