2011년 9월 22일 목요일

안드로이드 레이아웃 파라미터

RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        view.setLayoutParams(params);

2011년 9월 20일 화요일

안드로이드 기기번호 가져오기

TelephonyManager mgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); 

String imei = mgr.getDeviceId();

갤탭 갤플 null

퍼미션추가
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

안드로이드 자신의 전화번호 추출


TelephonyManager mTelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
returnValue = mTelephonyMgr.getLine1Number();


안되면

public static String getPhoneNumber(Context context)
{
        TelephonyManager tMgr =(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); 
        String phone = "";
        try{
        if(tMgr.getLine1Number()!=null){
         phone = tMgr.getLine1Number();
        }
        phone = phone.substring(phone.length()-10,phone.length());
        phone="0"+phone;
        }catch(Exception e){
         e.printStackTrace();
        }
        Log.d("Phone Number ",phone);
        return phone;
}


추가