다른 모든 질문은 ACTION_CALL 또는 ACTION_DIAL 또는 해당 주제에 대한 것입니다. 알 겠어. 나는 의도가 필요해. 하지만 어떻게 사용자 정의 다이얼러를 구현합니까? 검색하고 검색했으며이 주제와 관련된 내용을 찾을 수 없습니다. 나는 그것을 모두 고안하고, 갈 준비가되어 있지만, 그것을 함께 모으는 방법은 아무것도 없다.맞춤 다이얼러 UI 프로그래밍 및 구현
layout/activity_main.java에 요소와 스타일을 추가하는 것만 큼 간단 할 것이라고 생각했지만 그렇지 않았습니다. 지금까지 간단한 테스트만으로도 앱이 충돌로 인해 충돌을 일으켰습니다. Like :
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/title_two"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="phone"
android:maxLength="11" >
<requestFocus />
</EditText>
<Button
android:id="@+id/one"
android:text="1" />
<Button
android:id="@+id/two"
android:text="2" />
<Button
android:id="@+id/three"
android:text="3" />
<Button
android:id="@+id/four"
android:text="4" />
<Button
android:id="@+id/five"
android:text="5" />
<Button
android:id="@+id/six"
android:text="6" />
<Button
android:id="@+id/seven"
android:text="7" />
<Button
android:id="@+id/eight"
android:text="8" />
<Button
android:id="@+id/nine"
android:text="9" />
<Button
android:id="@+id/star"
android:text="*" />
<Button
android:id="@+id/zero"
android:text="0" />
<Button
android:id="@+id/pound"
android:text="#" />
<Button
android:id="@+id/callButton"
android:text="Call" />
<Button
android:id="@+id/contacts"
android:text="Con" />
<Button
android:id="@+id/del"
android:text="Del" />
내가보기에는 너무 쉽지만 모든 버튼을 추가하지 않고도 모든 버튼을 추가 할 수는 없습니다. src/MainActivity.java에서 다음과 같이 정의합니다.
public class MainActivity extends Activity {
Button dialBtn;
EditText numTxt;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dialBtn = (Button) findViewById(R.id.button1);
numTxt = (EditText) findViewById(R.id.editText1);
dialBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
if (numTxt != null && (numTxt.getText().length()==10 ||numTxt.getText().length()==11)) {
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel: 8880000000" + numTxt.getText())));
}else if(numTxt != null && numTxt.getText().length()==0){
Toast.makeText(getApplicationContext(), "You must enter a number to call", Toast.LENGTH_SHORT).show();
}else if(numTxt != null && numTxt.getText().length()<10){
Toast.makeText(getApplicationContext(), "Please check your number and try again", Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
Log.e("DialerActivity", "error: " + e.getMessage(), e);
}
}
});
}
}
여기서 유일한 목표는 사용자에게 다이얼러를 제공하는 것입니다. 그들은 전화 번호를 입력하고 일반 다이얼러처럼 화면에서 볼 수 있습니다. 그런 다음 서비스에 대한 하드 코드 된 액세스 번호를 호출 한 다음 eventListener가 응답으로 변경되면 전화 건 번호를 전달합니다.
나는이 점을 처음 접했기 때문에 몇 가지 눈에 띄는 실수가 있음을 인정할 것입니다. 백만 개의 고객 다이얼러가 있기 때문에 Android에서 할 수있는 가장 쉬운 방법 중 하나라고 생각했습니다. 나는 아무것도하지 않으려 고 노력하고 있습니다. 서비스를 사용하려면 앱을 사용해야합니다. 즉, BroadcastReceiver가 발신 통화를 가로 채고 서비스를 사용할지 확인하기 위해 백그라운드에서 걸어 다니지 않아야합니다. 그냥 간단한 전화 걸기 응용 프로그램. 내가 어디로 잘못 가고 있니? 이 코드 중 일부는 책, 온라인 자습서에서 바로 복사 할 수 있지만 작동 시키려고 노력하지만 곧바로 복사하여 붙여 넣을 수는 없습니까?
여기서 맞춤형 전화 걸기를 찾을 수 있습니다. https://github.com/Ali-Rezaei/PadLayout – Ali