1

ボタンのonClick()メソッドによる発信コールを切断すると、同じフラグメントに戻ることができます 私は、 //電話ダイアログのボタンをクリックして電話の活動はここ を開始している上、私はいくつかのコードと私の呼状態リスナーを入れて親切に私を助けてユーザが発信コールを切断したときに同じフラグメントに戻る方法

String temp = "tel:+91"+"xxxxxxxxxx"; 
        Intent callIntent = new Intent(Intent.ACTION_CALL); 
        callIntent.setData(Uri.parse(temp)); 
        startActivity(callIntent); 

//自分の携帯電話の通話状態リスナー

private class PhoneCallStateListener extends PhoneStateListener 
    { 
    private boolean isSystemCalling = false; 
     public void onCallStateChanged(int state, String incomingNumber) { 
      if (TelephonyManager.CALL_STATE_OFFHOOK == state) 
      { 
       isSystemCalling = true; 
      } 
      if (TelephonyManager.CALL_STATE_IDLE == state) 
      { 
       if (isSystemCalling) 
       { 
        if(!active) 
        { 
         db.update_activity(Utilities.CONST_SYS_STATUS,Utilities.STATUS_DEACTIVE); 
         update(); 
        } 
        else 
        { 
db.update_activity(Utilities.CONST_SYS_STATUS,Utilities.STATUS_ACTIVE); 
         update(); 
        } 
        isSystemCalling = false; 
       } 
      } 
     } 
    } 
を作りました

答えて

0

私は以下のコードを使用しています。それは呼び出し後に戻ります。

Uri number = Uri.parse("tel:" + contactNumber); 
Intent dial = new Intent(Intent.ACTION_CALL, number); 
if (ActivityCompat.checkSelfPermission(mContext, android.Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { 
           // TODO: Consider calling 
           // ActivityCompat#requestPermissions 
           // here to request the missing permissions, and then overriding 
           // public void onRequestPermissionsResult(int requestCode, String[] permissions, 
           //           int[] grantResults) 
           // to handle the case where the user grants the permission. See the documentation 
           // for ActivityCompat#requestPermissions for more details. 
    return; 
} 
mContext.startActivity(dial); 

これはあなたのために働く場合、それを使ってみてください。

+0

ええ、それは私が間違っていない場合、私はこの行の前に、startActivity(callIntent);右 ? –

+0

はい、それは私がコードで理解できる限り間違いでした。 とにかく、problem.Keepコーディングを解決した場合、回答を受け入れ可能とマークすることができます:) @ravi_koriya – Swr7der

関連する問題