2016-01-31 21 views
5

通話のユーザーインターフェイスを変更するにはどうすればよいですか?私は自分のダイヤラレイアウトと連絡先レイアウトを持っていますが、どのように呼び出しUIを変更するのですか?そのため、通話が行われているときに、たとえばスピーカーボタンを取り外すことはできますか?ここでAndroid電話の通話UI - 変更

は、私が作成した私のダイヤラシーンです:Dialer Picture

しかし、私は、この画面を編集する方法がわからない:Calling Picture

編集:私はすでにUIを構築している、私はできませんコール中にそれを表示する!

public class MainActivity extends Activity { 

private Button callBtn; 
private Button dialBtn; 
private EditText number; 

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

    number = (EditText) findViewById(R.id.phoneNumber); 
    callBtn = (Button) findViewById(R.id.call); 
    dialBtn = (Button) findViewById(R.id.dial); 

    // add PhoneStateListener for monitoring 
    MyPhoneListener phoneListener = new MyPhoneListener(); 
    TelephonyManager telephonyManager = 
     (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); 
    // receive notifications of telephony state changes 
    telephonyManager.listen(phoneListener,PhoneStateListener.LISTEN_CALL_STATE); 

    callBtn.setOnClickListener(new OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      try { 
       // set the data 
       String uri = "tel:"+number.getText().toString(); 
       Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(uri)); 

       startActivity(callIntent); 
      }catch(Exception e) { 
       Toast.makeText(getApplicationContext(),"Your call has failed...", 
        Toast.LENGTH_LONG).show(); 
       e.printStackTrace(); 
      } 
     } 
    }); 

    dialBtn.setOnClickListener(new OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      try { 
       String uri = "tel:"+number.getText().toString(); 
       Intent dialIntent = new Intent(Intent.ACTION_DIAL, Uri.parse(uri)); 

       startActivity(dialIntent); 
      }catch(Exception e) { 
       Toast.makeText(getApplicationContext(),"Your call has failed...", 
        Toast.LENGTH_LONG).show(); 
       e.printStackTrace(); 
      } 
     } 
    }); 
} 

private class MyPhoneListener extends PhoneStateListener { 

    private boolean onCall = false; 

    @Override 
    public void onCallStateChanged(int state, String incomingNumber) { 

     switch (state) { 
     case TelephonyManager.CALL_STATE_RINGING: 
      // phone ringing... 
      Toast.makeText(MainActivity.this, incomingNumber + " calls you", 
        Toast.LENGTH_LONG).show(); 
      break; 

     case TelephonyManager.CALL_STATE_OFFHOOK: 
      // one call exists that is dialing, active, or on hold 
      Toast.makeText(MainActivity.this, "on call...", 
        Toast.LENGTH_LONG).show(); 
      //because user answers the incoming call 
      onCall = true; 
      break; 

     case TelephonyManager.CALL_STATE_IDLE: 
      // in initialization of the class and at the end of phone call 

      // detect flag from CALL_STATE_OFFHOOK 
      if (onCall == true) { 
       Toast.makeText(MainActivity.this, "restart app after call", 
         Toast.LENGTH_LONG).show(); 

       // restart our application 
       Intent restart = getBaseContext().getPackageManager(). 
        getLaunchIntentForPackage(getBaseContext().getPackageName()); 
       restart.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
       startActivity(restart); 

       onCall = false; 
      } 
      break; 
     default: 
      break; 
     } 

    } 
} 
} 

ありがとう:ここ

は簡単なバージョンとしてのコードです!

+0

独自のダイヤラを作成 – TheSunny

+2

UIを構築しましたが、通話中にどのように表示させるのですか? –

答えて

-1

独自のダイヤラーUIを構築します。 thisを確認してください。 インテントを処理するためのアクティビティが必要です。カスタムUIを表示することはあなたのビジネスです。

+2

私はUIを構築しました!私はちょうどそれを表示する方法を知らない! –

+0

あなたがそのリンクに従うと文字通りあなたのアプリに意図をリダイレクトする方法を教えてくれます – TheSunny

5

はその後、コールボタンが押されているかどうかを確認する必要がマニフェスト

<uses-permission android:name="android.permission.CALL_PHONE" /> 

に許可を呼び出します。

<intent-filter> 
    <action android:name="android.intent.action.CALL_BUTTON" /> 
    <category android:name="android.intent.category.DEFAULT" /> 
</intent-filter> 

インテントフィルタ以下とマニフェストであなたの呼び出し元の活動がこの

<activity 
     android:name="com.example.MainActivity" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 

     <!-- open activity when establishing a call --> 
     <intent-filter> 
      <action android:name="android.intent.action.CALL_PRIVILEGED" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <data android:scheme="tel" /> 
     </intent-filter> 

    </activity> 
0

のようなもの実際の呼び出しビュー(何になることを意味し

<intent-filter> 
    <action android:name="android.intent.action.VIEW" /> 
    <action android:name="android.intent.action.DIAL" /> 
    <category android:name="android.intent.category.DEFAULT" /> 
    <category android:name="android.intent.category.BROWSABLE" /> 
    <data android:scheme="tel" /> 
</intent-filter> 

UI

を発射するときに使用するために通話中に表示されます)CAN'Tが変更されます。

具体的には、アンドロイドの一部は無効にすることはできません。アンドロイドにはそのコアがあり、開発者としてはこのコアへのアクセスが制限されています。 あなたのケースではダイヤラを無効にできますが、は実際の電話通話表示を無効にすることはできません。

アンドロイドのチームがこのコア機能を私たち(開発者)と共有することに決めたときまで、これについては何もすることはできません。

+0

もっと説明して、彼が望んでいることができないので、何ができるか教えてください。 – Arin

+0

アッシュ・パテルは「私は電話中に見せてもらえません!」と尋ねます。答えは:いいえ、誰もできないのでできません! –