Android Open Source - com.elsewhat.android.slideshow Android Utils






From Project

Back to project page com.elsewhat.android.slideshow.

License

The source code is released under:

Copyright (C) 2012 Dagfinn Parnas <dagfinn.parnas@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Sof...

If you think the Android project com.elsewhat.android.slideshow 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

package com.elsewhat.android.slideshow.api;
//  w  ww.  j  a  va  2s  .co  m
import android.content.Context;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class AndroidUtils {
  private static int sdkVersion;
   static 
   {
      try {
        sdkVersion = Integer.parseInt(android.os.Build.VERSION.SDK);
      } catch (Exception ex) {
      }
    }

    /** Device support the froyo (Android 2.2) APIs */
    public static boolean isAndroid22() {
      return sdkVersion >= 8;
    }

    /** Device supports the Honeycomb (Android 3.0) APIs */
    public static boolean isAndroid30() {
      return sdkVersion >= 11;
    }
    
    /**
     * Test if this device is a Google TV.
     * 
     * See 32:00 in "Google I/O 2011: Building Android Apps for Google TV"
     * http://www.youtube.com/watch?v=CxLL-sR6XfM
     * 
     * @return true if google tv
     */
    public static boolean isGoogleTV(Context context) {
        final PackageManager pm = context.getPackageManager();
        return pm.hasSystemFeature("com.google.android.tv");
    }
    
    public static boolean hasTelephony(Context context){
      PackageManager pm = context.getPackageManager();
      return pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
    }
    
    public static boolean isConnectedToWifi(Context context){
      ConnectivityManager connec = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
      NetworkInfo wifi = connec.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
       
      if (wifi!=null && wifi.isConnected()) {
            return true;
      } else {
        return false;
      }
  
    }
    
    public static boolean isConnectedToWired(Context context){
      ConnectivityManager connec = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
      //ConnectivityManager.TYPE_ETHERNET == 9 , but only from API 13
      
      NetworkInfo ethernet = connec.getNetworkInfo(9);
       
      if (ethernet!=null && ethernet.isConnected()) {
            return true;
      } else {
        return false;
      }
  
    }
    
    public static boolean isConnectedRoaming(Context context){
      ConnectivityManager connec = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
      NetworkInfo mobile = connec.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
       
      if (mobile!=null && mobile.isConnected() && mobile.isRoaming()){
            return true;
      } else {
        return false;
      }
    }
    
    
}




Java Source Code List

com.elsewhat.android.slideshow.activities.ChromecastAddin.java
com.elsewhat.android.slideshow.activities.ISlideshowInstance.java
com.elsewhat.android.slideshow.activities.SlideshowActivity.java
com.elsewhat.android.slideshow.activities.SlideshowDreamService.java
com.elsewhat.android.slideshow.activities.SlideshowPreferences.java
com.elsewhat.android.slideshow.api.Analytics.java
com.elsewhat.android.slideshow.api.AndroidUtils.java
com.elsewhat.android.slideshow.api.AsyncQueueableObject.java
com.elsewhat.android.slideshow.api.AsyncReadQueue.java
com.elsewhat.android.slideshow.api.CustomGallery.java
com.elsewhat.android.slideshow.api.DeletablePreference.java
com.elsewhat.android.slideshow.api.DownloadableObject.java
com.elsewhat.android.slideshow.api.FileDownloader.java
com.elsewhat.android.slideshow.api.FileUtils.java
com.elsewhat.android.slideshow.api.FlingKeyEvent.java
com.elsewhat.android.slideshow.api.ImageAdapter.java
com.elsewhat.android.slideshow.api.QueueablePhotoObject.java
com.elsewhat.android.slideshow.api.ReadOnlyPreference.java
com.elsewhat.android.slideshow.api.SlideshowBackend.java
com.elsewhat.android.slideshow.api.SlideshowPhotoCached.java
com.elsewhat.android.slideshow.api.SlideshowPhotoDrawable.java
com.elsewhat.android.slideshow.api.SlideshowPhoto.java
com.elsewhat.android.slideshow.backend.FlickrPublicSetBackend.java
com.elsewhat.android.slideshow.backend.OPMLBackend.java
com.elsewhat.android.slideshow.backend.SmugMugRecentBackend.java