android - Facebook app type no internet connection message -


how can show no internet connection message in facebook app appears below tab view.

facebook message

you can design in xml file , set visibility invisible this:

<relativelayout     android:id="@+id/relativelayout_connection"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignparentleft="true"     android:layout_alignparentright="true"     android:alpha="0.8"     android:background="@android:color/black" >      <textview         android:id="@+id/textview_nointernetconnection"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparenttop="true"         android:layout_centerhorizontal="true"         android:layout_centerinparent="true"         android:text="no internet connection."         android:textappearance="?android:attr/textappearancemedium"         android:textcolor="@android:color/white" />      <imageview         android:id="@+id/imageview2"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignbottom="@+id/textview_nointernetconnection"         android:layout_alignparenttop="true"         android:layout_toleftof="@+id/textview_nointernetconnection"         android:src="@drawable/warrning" /> </relativelayout> 

in code use broadcast receiver this:

private broadcastreceiver mconnreceiver = new broadcastreceiver() {      @override     public void onreceive(context context, intent intent) {         boolean noconnectivity = intent.getbooleanextra(                 connectivitymanager.extra_no_connectivity, false);         /*string reason = intent                 .getstringextra(connectivitymanager.extra_reason);*/         boolean isfailover = intent.getbooleanextra(                 connectivitymanager.extra_is_failover, false);          @suppresswarnings("deprecation")         networkinfo currentnetworkinfo = (networkinfo) intent                 .getparcelableextra(connectivitymanager.extra_network_info);         // networkinfo othernetworkinfo = (networkinfo)         // intent.getparcelableextra(connectivitymanager.extra_other_network_info);          if (noconnectivity){                 if(mrelativelayout != null)             mrelativelayout.setvisibility(view.visible);          }         else if (currentnetworkinfo.isconnected()) {             mrelativelayout.setvisibility(view.gone);           } else if (isfailover) {             toast.maketext(getapplicationcontext(), "failover",                     toast.length_long).show();         } else {             mrelativelayout.setvisibility(view.gone);                        }     }        }; 

Comments