Android Open Source - groundify-android Utility

From Project

Back to project page groundify-android.


The source code is released under:

GNU General Public License

If you think the Android project groundify-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*from w ww  .  j a  v  a 2  s.  c o  m*/
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import android.content.Context;
import android.util.Log;
import android.widget.Toast;

public class Utility {

  private final String TAG = "Utility";

  private boolean mConnected = false;

  public boolean isOnline(Context context) {
    try {
      Log.i(TAG, "Detect Connection");

      ConnectivityManager connectivityManager = (ConnectivityManager) context


      NetworkInfo networkInfo = connectivityManager
      mConnected = networkInfo != null && networkInfo.isAvailable()
          && networkInfo.isConnected();
      Log.i(TAG, "mConnected = " + mConnected);

    } catch (Exception e) {

      mConnected = false;
    Log.i(TAG, "mConnected = " + mConnected);

    return mConnected;

  public void toastMessage(Context cont, String message) {

    Toast.makeText(cont, message, Toast.LENGTH_LONG).show();


  public boolean isEmailValid (Context context, String email )
    String expression = "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$";
    CharSequence inputStr = email;
      Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
      Matcher matcher = pattern.matcher(inputStr);
    if (matcher.matches())
      return true ;
    else {

      return false ;

Java Source Code List