Check internet connection availability
Sometimes you have to check if Internet connectivity is available. The below code shows how to use Tizen Native APIs to check if there is a Wi-Fi or the Cellular network available.
#include <net_connection.h>
#include <dlog.h> //for logging purposes
bool internet_available = false;
connection_h connection;
connection_type_e type;
if (connection_create(&connection) == CONNECTION_ERROR_NONE)
{
if(connection_get_type(connection, &type) != CONNECTION_ERROR_NONE){
if(type == CONNECTION_TYPE_WIFI || type == CONNECTION_TYPE_CELLULAR){
LOGI("connection is available);
internet_available = true;
} else {
LOGI("connection is not available);
internet_available = false;
}
}
connection_destroy(connection);
}