public class MainActivity extends ActionBarActivity {
TextView connectionchecktextbox;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
connectionchecktextbox = (TextView) findViewById(R.id.connectionchecktextbox);
if (Utils.isNetworkAvailable(MainActivity.this)) {
connectionchecktextbox.setVisibility(View.GONE);
}
else {
connectionchecktextbox
.setText("It Seems Internet Connection if off");
}
}
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.popupdisplay.MainActivity$PlaceholderFragment" >
<TextView
android:id="@+id/connectionchecktextbox"
android:layout_width="fill_parent"
android:layout_height="25dip"
android:layout_alignParentBottom="true"
android:background="#F40C0C"
android:gravity="center"
android:text="It Seems Internert Connection if off"
android:textAlignment="gravity"
android:textColor="#ffffff" />
</RelativeLayout>
here is Xml
Using this code i am able to display Text message when device is Internet off and On but it display when we open app : means we have to call always on create to show this i want automatic text message should display when app is On then text message should disappear and when off then automatic that text message should appear please tell me how i to apply this