전화번호 추출후 string id = " " 로 보내기

전화번호 추출후 string id = " " 로 보내기

QA

전화번호 추출후 string id = " " 로 보내기

본문

3ba9fea4d0fa7b8a65723a56651249e4_1507521336_4239.jpg
 




아래 메인 자바 소스중 

String id = "15555215554";   이부분을 직접 입력해서 빌드하면 위와 같이 

그누보드 회원정보에서 포인트 정보를 잘 뽑아와서 보여줍니다


위 이미지중  15555215554 는    아래 메인 자바 소스중 내 폰번호를 추출해와서

textview 로 화면에 보여준 것입니다

제 핸드폰에 설치해서 확인해보면 제 폰번호가 정상적으로 보여집니다


그럼 디바이스 전화번호를 정상적으로 추출해 오는건 확인이 된거니까

이제 필요한건  추출한 전화번호를 textview 로 보여주는것이 아니라


String id =  ;    로 전화번호가 들어가게 하는 방법 입니다.


도와 주세요....


아래는 현재 메인 자바 소스입니다


public class zzzzzz extends AppCompatActivity {
TextView txtPhoneNo;
TextView txtview;
phpdo task;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zzzzzz);

String id = "15555215554";
         String name = "";

task = new phpdo();
txtview = (TextView) findViewById(R.id.txtView);
task.execute(id, name);

txtPhoneNo = (TextView)findViewById(R.id.txtPhoneNo);

int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE);

if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, 1);
} else {
//manager
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);

// 통신사 전화번호 구하기
txtPhoneNo.setText("전화번호"+ telephonyManager.getLine1Number().replace("-", "").replace("+82", "0"));
}
}

@Override
protected void onDestroy() {
super.onDestroy();
}

private class phpdo extends AsyncTask<String, Void, String> {

protected void onPreExecute() {

}

@Override
protected String doInBackground(String... arg0) {

try {
String id = arg0[0];

String link = "http://sun7684.dothome.co.kr/testquery.php?ID=" + id + "&NAME=" + name;
URL url = new URL(link);
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet();
request.setURI(new URI(link));
HttpResponse response = client.execute(request);
BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

StringBuffer sb = new StringBuffer("");
String line = "";

while ((line = in.readLine()) != null) {
sb.append(line);
break;
}
in.close();
return sb.toString();
} catch (Exception e) {
return new String("Exception: " + e.getMessage());
}

}

@Override
protected void onPostExecute(String result) {
//txtview.setText("Login Successful");
txtview.setText(result);

}

}

}

이 질문에 댓글 쓰기 :

답변 2

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(activity_zzzzzz);


int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE);


if (permissionCheck != PackageManager.PERMISSION_GRANTED) {

ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, 1);

} else {

TelephonyManager telephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);

String id = telephonyManager.getLine1Number().replace("+82", "0"); 


task = new phpdo();

txtview = (TextView) findViewById(R.id.txtView);

task.execute(id);

}

}

여기는 주로 그누보드, 영카트 등 관련내용과 PHP, Mysql, 서버관련 질문에

답하는 것이 주된 곳일 겁니다.


물론 안드로이드 등 자바에 능통하신 분들도 계시겠지만

안드로이드 관련 전용 질문게시판 보다는 답변이 늦겠죠.


구글 등 검색을 통해 안드로이드 전용 질문게시판을 이용하시는 것이

시간이나 에너지나 두루 좋으실걸로 보입니다.

답변을 작성하시기 전에 로그인 해주세요.
전체 130
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT