안 드 로 이 드 는 핸드폰 으로 전 화 를 걸 수 있 는 기능 을 실현 한다.
다음은 이 인 스 턴 스 를 개발 하 는 구체 적 인 절차 입 니 다.
1.아이 폰 콜 데모 라 는 안 드 로 이 드 프로젝트 를 새로 만 듭 니 다.
2.디자인 프로그램의 인터페이스,main.xml 를 열 어 내용 을 다음 과 같이 수정 합 니 다.
XML/HTML 코드
<?xml version="1.0" encoding="utf-8"?> 
 
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 
  android:orientation="vertical" 
 
  android:layout_width="fill_parent" 
 
  android:layout_height="fill_parent" 
 
  > 
 
  <TextView 
 
  android:layout_width="fill_parent" 
 
  android:layout_height="wrap_content" 
 
  android:text="Please input the phoneNumer:" 
 
  /> 
 
  <EditText 
 
  android:id="@+id/et1" 
 
  android:layout_width="fill_parent" 
 
  android:layout_height="wrap_content" 
 
  android:phoneNumber="true" 
 
  /> 
 
  <Button 
 
  android:id="@+id/bt1" 
 
  android:layout_width="wrap_content" 
 
  android:layout_height="wrap_content" 
 
  android:text="Call Phone" 
 
  /> 
 
  </LinearLayout>   3.전 화 를 걸 수 있 는 권한 을 늘 리 고 AndroidManifest.xml 를 켜 면 다음 과 같이 코드 를 수정 합 니 다.XML/HTML 코드
<?xml version="1.0" encoding="utf-8"?> 
 
  <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
 
  package="com.android.test" 
 
  android:versionCode="1" 
 
  android:versionName="1.0"> 
 
  <application android:icon="@drawable/icon" android:label="@string/app_name"> 
 
  <activity android:name=".PhoneCallDemo" 
 
  android:label="@string/app_name"> 
 
  <intent-filter> 
 
  <action android:name="android.intent.action.MAIN" /> 
 
  <category android:name="android.intent.category.LAUNCHER" /> 
 
  </intent-filter> 
 
  </activity> </application> 
 
  <uses-sdk android:minSdkVersion="3" />  
 
  <uses-permission android:name="android.permission.CALL_PHONE"> 
 
  </uses-permission> 
 
  </manifest>  4.메 인 프로그램 phoneCallDemo.java 코드 는 다음 과 같 습 니 다.
 package com.android.test;import android.app.Activity; 
 
  import android.content.Intent; 
 
  import android.net.Uri; 
 
  import android.os.Bundle; 
 
  import android.view.View; 
 
  import android.widget.Button; 
 
  import android.widget.EditText; 
 
  import android.widget.Toast;
 
 public class PhoneCallDemo extends Activity { 
 
  private Button bt; 
 
  private EditText et; 
 
  public void onCreate(Bundle savedInstanceState) { 
 
  super.onCreate(savedInstanceState); 
 
  setContentView(R.layout.main); 
 
  //     
 
  bt = (Button)findViewById(R.id.bt1); 
 
  et = (EditText)findViewById(R.id.et1); 
 
  //       
 
  bt.setOnClickListener(new Button.OnClickListener(){ @Override 
 
  public void onClick(View v) { 
 
  //           
 
  String inputStr = et.getText().toString(); 
 
  //             Intent 
 
  if(inputStr.trim().length()!=0) 
 
  { 
 
  Intent phoneIntent = new Intent("android.intent.action.CALL", 
 
  Uri.parse("tel:" + inputStr)); 
 
  //   
 
  startActivity(phoneIntent); 
 
  } 
 
  //  Toast     
 
  else{ 
 
  Toast.makeText(PhoneCallDemo.this, "      ", Toast.LENGTH_LONG).show(); 
 
  } 
 
  } 
 
  }); 
 
  } 이상 은 안 드 로 이 드 개발 이 전 화 를 거 는 간단 한 예 입 니 다.추 후 관련 자 료 를 계속 보충 하 겠 습 니 다.본 사이트 에 대한 여러분 의 지지 에 감 사 드 립 니 다!
                이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Bitrise에서 배포 어플리케이션 설정 테스트하기이 글은 Bitrise 광고 달력의 23일째 글입니다. 자체 또는 당사 등에서 Bitrise 구축 서비스를 사용합니다. 그나저나 며칠 전 Bitrise User Group Meetup #3에서 아래 슬라이드를 발표했...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.