Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/* AudioHelper.java
    
 Copyright (c) 2010 Ethan Chen
    
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.
    
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
    
 You should have received a copy of the GNU General Public License along
 with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

import android.util.Log;

public class Main {
    private static final String TAG_AUDIOHELPER = "AudioHelper";
    private static final String MANUFACTURER_SAMSUNG = "samsung";
    private static final String DEVICE_ID_GALAXY_S = "gt-i9000";
    private static final String DEVICE_ID_CAPTIVATE = "sgh-i897";
    private static final String DEVICE_ID_VIBRANT = "sgh-t959";
    private static final String DEVICE_ID_FASCINATE = "sch-i500";
    private static final String DEVICE_ID_EPIC = "sph-d700";
    private static final String DEVICE_ID_MESMERIZE = "sch-i500";

    /**
     * Tries to figure out if the current phone is Galaxy S based, since it has
     * recording issues This is pretty nasty since we are string matching, but
     * unless I can get a better way to do it...
     * 
     * @param
     */
    public static boolean isSamsungGalaxyS() {
        String manufacturer = android.os.Build.MANUFACTURER.toLowerCase();
        String model = android.os.Build.MODEL.toLowerCase();
        String device = android.os.Build.DEVICE.toLowerCase();
        Log.i(TAG_AUDIOHELPER,
                String.format("manufacturer: %s, model: %s, device: %s", manufacturer, model, device));

        if (manufacturer.equals(MANUFACTURER_SAMSUNG)) {
            if (device.equals(DEVICE_ID_GALAXY_S)) {
                Log.i(TAG_AUDIOHELPER, "Samsung Galaxy S detected");
                return true;
            }

            if (device.equals(DEVICE_ID_CAPTIVATE)) {
                Log.i(TAG_AUDIOHELPER, "ATT, Samsung Captivate detected");
                return true;
            }

            if (device.equals(DEVICE_ID_VIBRANT)) {
                Log.i(TAG_AUDIOHELPER, "T-Mobile US, Samsung Vibrant detected");
                return true;
            }

            if (device.equals(DEVICE_ID_EPIC)) {
                Log.i(TAG_AUDIOHELPER, "Sprint, Samsung Epic 4G detected");
                return true;
            }

            if (device.equals(DEVICE_ID_FASCINATE)) {
                Log.i(TAG_AUDIOHELPER, "Verizon, Samsung Fascinate detected");
                return true;
            }

            if (device.equals(DEVICE_ID_MESMERIZE)) {
                Log.i(TAG_AUDIOHELPER, "Samsung Mesmerize detected");
                return true;
            }
        }
        return false;
    }
}