Example usage for android.telephony TelephonyManager getSimSerialNumber

List of usage examples for android.telephony TelephonyManager getSimSerialNumber

Introduction

In this page you can find the example usage for android.telephony TelephonyManager getSimSerialNumber.

Prototype

@SuppressAutoDoc 
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
public String getSimSerialNumber() 

Source Link

Document

Returns the serial number of the SIM, if applicable.

Usage

From source file:dev.dworks.apps.asecure.MainActivity.java

private void setNewData() {
    TelephonyManager localTelephonyManager = (TelephonyManager) getApplicationContext()
            .getSystemService(Activity.TELEPHONY_SERVICE);
    operatorName = localTelephonyManager.getSimOperatorName();
    simSerial = localTelephonyManager.getSimSerialNumber();
    if (TelephonyManager.SIM_STATE_READY == localTelephonyManager.getSimState()) {
        operator.setText(operatorName);/*from w  w  w  .  j a v a 2 s .  c  o m*/
        number.setText(simSerial);
        simQueryHandler = new SIMQueryHandler(getContentResolver());
        simQueryHandler.startQuery(0, null, SecureSIM.CONTENT_URI, PROJECTION,
                SecureSIMColumns.SIM_NUMBER + " = ? ", new String[] { simSerial }, null);
    } else {
        operator.setText("Unknown");
        number.setText("-");
        register.setImageResource(0);
        register.setOnClickListener(null);
    }
}

From source file:de.ub0r.android.otpdroid.OTPdroid.java

/**
 * Load IMEI and SIMID from phone./*from   ww w  . ja va 2  s.c o  m*/
 */
private void loadKeys() {
    TelephonyManager phone = (TelephonyManager) this.getApplicationContext()
            .getSystemService(Context.TELEPHONY_SERVICE);

    this.imei = phone.getDeviceId();
    this.simid = phone.getSimSerialNumber();
}

From source file:jp.gr.java_conf.ya.shiobeforandroid3.UpdateTweetDrive.java

@Override
protected final void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build());
    }// w  ww . ja  v  a2 s . c om

    simpleauth();

    crpKey = getString(R.string.app_name);
    final TelephonyManager telephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    crpKey += telephonyManager.getDeviceId();
    crpKey += telephonyManager.getSimSerialNumber();
    try {
        final PackageInfo packageInfo = getPackageManager()
                .getPackageInfo("jp.gr.java_conf.ya.shiobeforandroid3", PackageManager.GET_META_DATA);
        crpKey += Long.toString(packageInfo.firstInstallTime);
    } catch (NameNotFoundException e) {
        WriteLog.write(this, e);
    }

    adapter = new ListAdapter(this, crpKey, null, null);

    setContentView(R.layout.tweet_drive);
    tableLayout1 = (TableLayout) this.findViewById(R.id.tableLayout1);
    editText2 = (EditText) this.findViewById(R.id.editText2);
    editText4 = (EditText) this.findViewById(R.id.editText4);
    editText5 = (EditText) this.findViewById(R.id.editText5);
    editText2.setFocusable(true);
    editText2.setFocusableInTouchMode(true);
    editText2.requestFocusFromTouch();

    pref_app = PreferenceManager.getDefaultSharedPreferences(this);

    final String pref_tl_fontfilename = pref_app.getString("pref_tl_fontfilename", "");
    if (pref_tl_fontfilename.equals("") == false) {
        try {
            WriteLog.write(this, "pref_tl_fontfilename: " + pref_tl_fontfilename);
            fontUtil.loadFont(pref_tl_fontfilename, this);

            fontUtil.setFont(editText2, this);
            fontUtil.setFont(editText4, this);
            fontUtil.setFont(editText5, this);
        } catch (final Exception e) {
            WriteLog.write(this, e);
        }
    }

    final float pref_tl_fontsize_updatetweet = ListAdapter.getPrefFloat(this, "pref_tl_fontsize_updatetweet",
            "14");
    editText2.setTextSize(pref_tl_fontsize_updatetweet);
    editText4.setTextSize(pref_tl_fontsize_updatetweet);
    editText5.setTextSize(pref_tl_fontsize_updatetweet);

    final String pref_tl_bgcolor_updatetweet = pref_app.getString("pref_tl_bgcolor_updatetweet", "#000000");
    pref_tl_fontcolor_text_updatetweet = pref_app.getString("pref_tl_fontcolor_text_updatetweet", "#ffffff");
    pref_tl_fontcolor_text_updatetweet_over = pref_app.getString("pref_tl_fontcolor_text_updatetweet_over",
            "#ff0000");

    if (pref_tl_bgcolor_updatetweet.equals("") == false) {
        try {
            tableLayout1.setBackgroundColor(Color.parseColor(pref_tl_bgcolor_updatetweet));
        } catch (final IllegalArgumentException e) {
        }
    }
    setTextColorOnTextChanged();
    if (pref_tl_fontcolor_text_updatetweet.equals("") == false) {
        try {
            editText4.setTextColor(Color.parseColor(pref_tl_fontcolor_text_updatetweet));
            editText5.setTextColor(Color.parseColor(pref_tl_fontcolor_text_updatetweet));
        } catch (final IllegalArgumentException e) {
        }
    }

    editText2.addTextChangedListener(new TextWatcher() {
        @Override
        public final void afterTextChanged(final Editable s) {
            setTextColorOnTextChanged();
        }

        @Override
        public final void beforeTextChanged(final CharSequence s, final int start, final int count,
                final int after) {
        }

        @Override
        public final void onTextChanged(final CharSequence s, final int start, final int before,
                final int count) {
            setTextColorOnTextChanged();
        }
    });
    editText2.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public final void onFocusChange(final View arg0, final boolean arg1) {
            setTextColorOnTextChanged();
        }
    });

    editText2.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public final boolean onLongClick(final View v) {
            tweet();
            return true;
        }
    });

    map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

    final String pref_map_site = pref_app.getString("pref_map_site", "0");
    if (pref_map_site.equals("0")) {
        try {
            MapsInitializer.initialize(this);
        } catch (final Exception e) {
            toast("You must update Google Google Play Service.");
        }
    } else {
        try {
            map.setMapType(GoogleMap.MAP_TYPE_NONE);

            final TileProvider tileProvider = new UrlTileProvider(256, 256) {
                @Override
                public final synchronized URL getTileUrl(final int x, final int y, final int zoom) {
                    // The moon tile coordinate system is reversed.  This is not normal.
                    // int reversedY = (1 << zoom) - y - 1;
                    // String s = String.format(Locale.US, MOON_MAP_URL_FORMAT, zoom, x, reversedY);
                    final String s = String.format(Locale.US,
                            ((pref_map_site.equals("0")) ? ListAdapter.OSM_MAP_URL_FORMAT
                                    : ListAdapter.GSI_MAP_URL_FORMAT),
                            zoom, x, y);
                    URL url = null;
                    try {
                        url = new URL(s);
                    } catch (final MalformedURLException e) {
                        throw new AssertionError(e);
                    }
                    return url;
                }
            };

            map.addTileOverlay(new TileOverlayOptions().tileProvider(tileProvider));
        } catch (final Exception e) {
            try {
                MapsInitializer.initialize(this);
            } catch (final Exception e1) {
                toast("You must update Google Maps.");
            }
        }
    }

    moveTo(35.66279, 139.759848, 0.0f, 0.0f);
}

From source file:com.prey.PreyPhone.java

public String getSimSerialNumber() {
    TelephonyManager tManager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    String simSerialNumber = "";
    try {//from ww w .  ja va2s .  co  m
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (ctx.checkSelfPermission(
                    android.Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
                simSerialNumber = tManager.getSimSerialNumber();
            }
        } else {
            simSerialNumber = tManager.getSimSerialNumber();
        }
    } catch (Exception e) {
        PreyLogger.e("Error getSimSerialNumber:" + e.getMessage(), e);
    }
    PreyLogger.d("simSerialNumber[" + simSerialNumber + "]");
    return simSerialNumber;
}

From source file:tw.com.sti.store.api.android.AndroidApiService.java

private AndroidApiService(Context context, Configuration config) {
    this.config = config;
    this.apiUrl = new ApiUrl(config);
    if (Logger.DEBUG)
        L.d("new ApiService()");

    sdkVer = Build.VERSION.SDK;/*www. ja  v a 2  s .  co m*/
    sdkRel = Build.VERSION.RELEASE;
    try {
        PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(),
                PackageManager.GET_ACTIVITIES);
        storeId = pi.packageName;
        clientVer = "" + pi.versionCode;
    } catch (NameNotFoundException e) {
    }
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    deviceId = tm.getDeviceId() == null ? "0" : tm.getDeviceId();
    macAddress = NetworkUtils.getDeviceMacAddress(context);
    subscriberId = tm.getSubscriberId() == null ? "0" : tm.getSubscriberId();
    simSerialNumber = tm.getSimSerialNumber() == null ? "0" : tm.getSimSerialNumber();

    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    try {
        Class<Display> cls = Display.class;
        Method method = cls.getMethod("getRotation");
        Object retobj = method.invoke(display);
        int rotation = Integer.parseInt(retobj.toString());
        if (Surface.ROTATION_0 == rotation || Surface.ROTATION_180 == rotation) {
            wpx = "" + display.getWidth();
            hpx = "" + display.getHeight();
        } else {
            wpx = "" + display.getHeight();
            hpx = "" + display.getWidth();
        }
    } catch (Exception e) {
        if (display.getOrientation() == 1) {
            wpx = "" + display.getHeight();
            hpx = "" + display.getWidth();
        } else {
            wpx = "" + display.getWidth();
            hpx = "" + display.getHeight();
        }
    }

    SharedPreferences pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
    //      token = pref.getString(PREF_KEY_TOKEN, "");
    //      uid = pref.getString(PREF_KEY_UID, "");
    //      userId = pref.getString(PREF_KEY_USER_ID, "");
    appFilter = pref.getInt(PREF_KEY_APP_FILTER, 0);
    // ipLoginEnable = pref.getBoolean(PREF_KEY_IP_LOGIN_ENABLE, true);

    // ??SIM?
    String pref_subscriberId = pref.getString(PREF_KEY_SUBSCRIBER_ID, "0");
    String pref_simSerialNumber = pref.getString(PREF_KEY_SIM_SERIAL_NUMBER, "0");
    if (!subscriberId.equals(pref_subscriberId) || !simSerialNumber.equals(pref_simSerialNumber)) {
        if (Logger.DEBUG)
            L.d("Change SIM card.");
        cleanCredential(context);
    }
    this.getCredential(context);
}

From source file:pandroid.agent.PandroidAgentListener.java

/**
 *    Retrieves the simID of the device if available
 *///from  w w  w  .  j a  va2  s  .c o  m
private void getSimID() {

    String simID = getSharedData("PANDROID_DATA", "simID", Core.defaultSimID, "string");

    String serviceName = Context.TELEPHONY_SERVICE;
    TelephonyManager telephonyManager = (TelephonyManager) getApplicationContext()
            .getSystemService(serviceName);
    simID = telephonyManager.getSimSerialNumber();
    putSharedData("PANDROID_DATA", "simID", simID, "string");
}

From source file:com.mb.android.MainActivity.java

@android.webkit.JavascriptInterface
@org.xwalk.core.JavascriptInterface/*from   w  w w .j a  v  a  2s.  c om*/
public String getLegacyDeviceId() {

    Context context = getApplicationContext();
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

    String uuid;
    String androidID = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
    String deviceID = tm.getDeviceId();
    String simID = tm.getSimSerialNumber();

    if ("9774d56d682e549c".equals(androidID) || androidID == null) {
        androidID = "";
    }

    if (deviceID == null) {
        deviceID = "";
    }

    if (simID == null) {
        simID = "";
    }

    uuid = androidID + deviceID + simID;
    uuid = String.format("%32s", uuid).replace(' ', '0');
    uuid = uuid.substring(0, 32);
    uuid = uuid.replaceAll("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5");

    return uuid;
}

From source file:com.lewa.crazychapter11.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    //set to full screen
    // getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  WindowManager.LayoutParams.FLAG_FULLSCREEN);

    ///set to no title
    // requestWindowFeature(Window.FEATURE_NO_TITLE);
    // acionBar = getSupportActionBar();
    // acionBar = getActionBar();
    // acionBar.hide();

    // Window win = getWindow();
    //          win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    //          win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS  | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);  
    //          win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);  
    // win.setStatusBarColor(Color.TRANSPARENT);  
    // win.setNavigationBarColor(Color.TRANSPARENT);

    /*//*  w  ww  .  j  a va 2s .  co  m*/
       win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
       win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS  | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);  
       win.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN  | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION  | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);  
       win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);  
       win.setStatusBarColor(Color.TRANSPARENT);  
       win.setNavigationBarColor(Color.TRANSPARENT);
    //*/

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    /* setTheme(R.style.CrazyTheme); */
    AddGameBtn();
    AddNoification();
    LookupContact();
    AddServiceBtn();
    broadcastMain();
    mediaPlayerMain();
    mediaRecordSoundMain();
    cameraMain();
    recordvideoMain();
    queMySql();
    TestFragment();
    justForTest();
    LoadJson();
    AddTestBtn();
    AddUsageStatsBtn();
    AddPeopleProvideBtn();
    getInput();

    ////just for test shutdown broadcast receiver
    IntentFilter mIntentFilter = new IntentFilter("android.intent.action.ACTION_SHUTDOWN");
    mIntentFilter.addAction("com.lewa.alarm.test");
    mIntentFilter.addAction("android.provider.Telephony.SECRET_CODE");
    mIntentFilter.addAction("android.intent.action.SCREEN_ON");
    mIntentFilter.addAction("android.intent.action.SCREEN_OFF");
    mShoutdown = new shutdownReceiver();
    registerReceiver(mShoutdown, mIntentFilter);
    ////test      

    preferences = getSharedPreferences("crazyit", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE);
    editor = preferences.edit();

    preferencestime = getSharedPreferences("RMS_Shutdown_time", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE);
    editortime = preferencestime.edit();

    SharedShutdownTimeRead();

    AddSharedPreBtn();

    etNum = (EditText) findViewById(R.id.etNum);

    // //
    int maxLength = 4;

    InputFilter[] fArray = new InputFilter[1];

    fArray[0] = new InputFilter.LengthFilter(maxLength);

    etNum.setFilters(fArray);
    // //

    calThread = new CalThread();
    calThread.start();

    Log.i("algerheMain", "MainActivity onCreate in!!");
    String page = getString(R.string.str_page, "345", "24");
    Log.i("algerheMain", "page=" + page);

    // /just for test here
    ComponentName comp = getIntent().getComponent();
    show_txt = (EditText) findViewById(R.id.show_txt);
    show_txt.setText(
            "??" + comp.getPackageName() + " \n ??" + comp.getClassName());

    ////MD5 check item
    ///1.IMEI
    TelephonyManager TelephonyMgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    String szImei = TelephonyMgr.getDeviceId();
    String m_szSIMSerialNm = TelephonyMgr.getSimSerialNumber();
    CellLocation m_location = TelephonyMgr.getCellLocation();
    String m_Line1Number = TelephonyMgr.getLine1Number();
    String m_OperatorName = TelephonyMgr.getSimOperatorName();
    Log.i("algerheTelephonyMgr", "szImei=" + szImei);
    Log.i("algerheTelephonyMgr", "m_szSIMSerialNm=" + m_szSIMSerialNm);
    Log.i("algerheTelephonyMgr", "m_location=" + m_location);
    Log.i("algerheTelephonyMgr", "m_Line1Number=" + m_Line1Number);
    Log.i("algerheTelephonyMgr", "m_OperatorName=" + m_OperatorName);

    Log.i("algerheMain01", "szImei=" + szImei);
    Log.i("algerheMain01", "m_szSIMSerialNm=" + m_szSIMSerialNm);

    ///2.Pseudo-Unique ID
    String m_szDevIDShort = "35" + //we make this look like a valid IMEI 
            Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10
            + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10
            + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10
            + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10
            + Build.USER.length() % 10; //13 digits

    Log.i("algerheMain01", "m_szDevIDShort=" + m_szDevIDShort);

    ///3. Android ID
    String m_szAndroidID = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
    Log.i("algerheMain01", "m_szAndroidID=" + m_szAndroidID);

    ///4.WLAN MAC Address string
    WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    String m_szWLANMAC = "unknow_wifi_mac";
    if (wm != null && wm.getConnectionInfo() != null) {
        m_szWLANMAC = wm.getConnectionInfo().getMacAddress();
    }

    Log.i("algerheMain01", "m_szWLANMAC=" + m_szWLANMAC);

    ///5.BT MAC Address string
    BluetoothAdapter m_BluetoothAdapter = null; // Local Bluetooth adapter      
    m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    String m_szBTMAC = m_BluetoothAdapter.getAddress();

    Log.i("algerheMain01", "m_szBTMAC=" + m_szBTMAC);

    ///6.sim serial number .getSimSerialNumber()

    // /

    ///reflect test   
    checkMethod();

    // */
    final Intent alarmIntent = new Intent();
    Log.i("algerheMain00", "isLewaRom=" + isLewaRom(this, alarmIntent));

    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (msg.what == 0x4567) {
                String languageStr = null;
                String countryStr = null;

                Locale[] locList = Locale.getAvailableLocales();

                for (int i = 0; i < locList.length; i++) {
                    languageStr += locList[i].getLanguage();
                    countryStr += locList[i].getCountry();
                }
                // show_txt = (EditText) findViewById(R.id.show_txt);
                show_txt.setText("" + languageStr + " \n " + countryStr);
            } else if (msg.what == 0x2789) {
                Log.i("algerheAlarm", "send alarm message in time=" + System.currentTimeMillis() + "\n action="
                        + alarmIntent.getAction());

                // sendBroadcast(alarmIntent);
            }
        }
    };

    // String strApkPath = intent.getStringExtra("apkPath");
    //         String strCmd = "pm install -r " + strApkPath;
    //         try {
    //             Process install = Runtime.getRuntime().exec(strCmd);
    //             Log.d(TAG, "install = " + install + ", strCmd =" + strCmd);
    //         }catch (Exception ex){
    //             Log.d(TAG, ex.getMessage());
    //         }   
    // */
}

From source file:com.guardtrax.ui.screens.HomeScreen.java

private String get_sim() {
    TelephonyManager telemamanger = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    String getSimSerialNumber = telemamanger.getSimSerialNumber();
    //String getSimNumber = telemamanger.getLine1Number();
    return getSimSerialNumber;
}