How can i check whether i am connected to internet or not using api code?