Quantcast
Channel: Take an xml feed from the internet and put it in my assets - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by user2157571 for Take an xml feed from the internet and put it in my assets

$
0
0

Add this method to your activity:

private boolean isNetworkAvailable() {
    ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetworkInfo = connectivityManager
            .getActiveNetworkInfo();
    return activeNetworkInfo != null;
}

and in onCreate or before you load your feed check like this:

        if (!isNetworkAvailable()) {
            Toast.makeText(
                    Player.this,
                    "No active internet connection found.",
                    Toast.LENGTH_LONG).show();
            finish();
            return;
        }

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles



Latest Images