2011-07-27 6 views
0

응용 프로그램을 만들려고합니다. SMS를 보낼 수 있으며 makin 호출 (USSD 코드 가져 오기)이 있습니다. 문제가 있습니다. SMS 작동을 보낼 수 없습니다. 내 응용 프로그램은 항상 닫습니다. 도와 줄수있으세요. 이것은 내 코드이고, 일부는 표시되어 있고, 버튼을 눌렀을 때 SMS를 보낼 필요가 있고 문장이 옳다. 도와주세요.SMS 전송과 함께 응용 프로그램이 작동하지 않습니다.

public class Stanje extends Activity { 
    private EditText text; 


    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
     text = (EditText) findViewById(R.id.editText1); 

    } 

    public boolean onCreateOptionsMenu(Menu menu) { 
     MenuInflater inflater = getMenuInflater(); 
     inflater.inflate(R.menu.menu, menu); 
     return true; 
    } 



    public void myClickHandler(View view) { 
     CheckBox TmobileBox = (CheckBox) findViewById(R.id.checkBox1); 
     CheckBox Tmobile2Box = (CheckBox) findViewById(R.id.checkBox2); 
     CheckBox BonbonBox = (CheckBox) findViewById(R.id.checkBox3); 
     String encodedHash = Uri.encode("#"); 
     text = (EditText) findViewById(R.id.editText1); 
     long inputValue1 = Long.parseLong(text.getText().toString()); 

     switch (view.getId()) { 
     case R.id.button1: 

      if(TmobileBox.isChecked()== true && Tmobile2Box.isChecked()== false && 
          BonbonBox.isChecked()==false){ 

    ******When this button is pressed, and first checkbox i checked, I need to send an SMS "S" to 
      number 3636****** 

      }else if (TmobileBox.isChecked()== false && Tmobile2Box.isChecked()== true 
          && BonbonBox.isChecked()==false) { 


       startActivity(new Intent("android.intent.action.CALL", 
        Uri.parse("tel:*100" + encodedHash))); 

      }else if (TmobileBox.isChecked()== false && Tmobile2Box.isChecked()== false 
          && BonbonBox.isChecked()==true) { 


       startActivity(new Intent("android.intent.action.CALL", 
        Uri.parse("tel:*100" + encodedHash))); 


      }else{ 

       Toast.makeText(getApplicationContext(), "Odaberi svog operatera! 
            (Samo jednog)", Toast.LENGTH_SHORT).show(); 
      } 

      break; 

     case R.id.button2: 

      if(TmobileBox.isChecked()== true && Tmobile2Box.isChecked()== false && 
        BonbonBox.isChecked()==false){ 

    ******When this button is pressed, and first checkbox i checked, I need to send an SMS "A" to 
      number 0977******  

      }else if (TmobileBox.isChecked()== false && Tmobile2Box.isChecked()== true 
         && BonbonBox.isChecked()==false) { 

    ******When this button is pressed, and first checkbox i checked, I need to send an SMS "STANJE" 
      to number 700****** 


      }else if (TmobileBox.isChecked()== false && Tmobile2Box.isChecked()== false 
         && BonbonBox.isChecked()==true) { 


      }else{ 

       Toast.makeText(getApplicationContext(), "Odaberi svog operatera! 
           (Samo jednog)", Toast.LENGTH_SHORT).show(); 
      } 

      break; 



     } 
    } 
} 
+0

logcat 추적 출력을 붙여 넣습니다. 앱이 충돌하게 만드는 또 다른 문제 일 수 있습니다. –

답변

1

SMS를 보내려면 Manifest에 대한 권한이 있습니까?

<uses-permission android:name="android.permission.SEND_SMS"> 

제안 : 왜 RadioGroup를 구현하는 코드의 길이에 잘라 해달라고? 코드 길이를 줄이면 ...

관련 문제