2012-07-04 41 views
0

我在我的android應用程序中實現了一個調用意圖。但是,每次點擊按鈕時,應用程序都會關閉。我已將android.permission.CALL_PHONE添加到我的清單中。另外,電子郵件按鈕工作正常。強制關閉調用意圖

我使用下面的代碼獲取從MySQL數據庫的數量:

phonenumber = json_data.getString("phone"); 

,這是OnClickListener的按鈕

call.setOnClickListener(new View.OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       // TODO Auto-generated method stub 
       String number = phonenumber; 
       Intent callintent = new Intent(android.content.Intent.ACTION_CALL); 
       callintent.putExtra(android.content.Intent.EXTRA_PHONE_NUMBER, number); 
       startActivity(callintent); 
      } 
     }); 

有沒有用使用該字符串的一個問題,因爲JSON數據轉換爲字符串?

+3

發佈工作就像魅力的日誌跟蹤 – Orlymee

回答

2

剛剛嘗試這一點,

String number = phonenumber; 
Intent callintent = new Intent(android.content.Intent.ACTION_CALL, Uri.parse("tel:"+number)); 
startActivity(callintent); 
+0

。謝謝 :) – rahulritesh