내 폰 번호 불러 오기
본문
public class zzzzzz extends AppCompatActivity {
TextView txtview;
phpdo task;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zzzzzz);
String id = "★★★";
String name = "";
task = new phpdo();
txtview = (TextView) findViewById(R.id.txtView);
task.execute(id, name);
}
위 "★★★" 부분에 내 폰번호를 불러 오려고 하는데요
잘 모르겠습니다...
답변 1
public class zzzzzz extends AppCompatActivity {
TextView txtview;
phpdo task;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zzzzzz);
String id = myPhoneNumber();
String name = "";
task = new phpdo();
txtview = (TextView) findViewById(R.id.txtView);
task.execute(id, name);
}
public static String myPhoneNumber() {
String myNumber = null;
TelephonyManager mgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
try{
myNumber = mgr.getLine1Number();
myNumber = myNumber.replace("+82", "0");
}catch(Exception e){}
return myNumber;
}
}
답변을 작성하시기 전에 로그인 해주세요.