Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Copyright [2013] [Nazmul Idris]
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import android.content.*;

import android.telephony.*;

public class Main {
    /**
     * Nazmul's Droid 2 - A00000226E8480
     * Izabels' LG Ally - A000002121A9F0
     * Simulator        - 000000000000000
     * Neil Hanna's Droid X - A0000022436CA0
     * Izzy's HTC Incredible - A1000013776A46
     * Nazmul's HTC Incredible - A1000013783B65
     */
    public static boolean isDeviceAuthorized(Context ctx) {

        String deviceid = getDeviceId(ctx);
        if (deviceid.equals("000000000000000") || deviceid.equals("A00000226E8480")
                || deviceid.equals("A000002121A9F0") || deviceid.equals("A1000013776A46")
                || deviceid.equals("A1000013783B65") || deviceid.equals("A0000022436CA0")) {
            return true;
        } else {
            return false;
        }

    }

    public static String getDeviceId(Context ctx) {
        TelephonyManager telephonyManager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
        String deviceid = telephonyManager.getDeviceId();
        return deviceid;
    }
}