Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Code Snippets - Android

RSS
Modified on Tue, Jun 18, 2013, 11:50 AM by Administrator Categorized as Android

Toast

A "toast" is a small popup near the bottom of the screen.

Toast.makeText(getApplicationContext(), "Hello, world!", Toast.LENGTH_SHORT).show();

Network Connectivity

private boolean isWifiConn;
private boolean isMobilConn;

public boolean checkForNetwork()
{
    ConnectivityManager connMan = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);

    NetworkInfo wifiConn = connMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    NetworkInfo mobileConn = connMan.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);

    isWifiConn = (wifiConn != null) && (wifiConn.isConnected());        	
    isMobilConn = (mobileConn != null) && (mobileConn.isConnected());

    return isWifiConn || isMobilConn;
}

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.