[안드로이드] 내 기지국 위치 확인 하기 (Cell ID-CID, LAC 찾기)

2014. 3. 21. 10:12Programing/Android / Java

소스 추가

        TelephonyManager tm  =

                (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

        

        GsmCellLocation location = (GsmCellLocation) tm.getCellLocation();


        int cellID  = location.getCid();

        int lac     = location.getLac();


        TextView mTextView = (TextView) findViewById(R.id.textView);

        mTextView.setText("Cell ID : " + String.valueOf(cellID) + "\n LAC : " + String.valueOf(lac));


권한 추가

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>


레이아웃 추가

    <TextView

        android:id="@+id/textView"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="lca_cid" />