0
我正在嘗試製作一個應用程序,這是可能的發送短信和makin調用(geting USSD代碼)我有問題。我無法發送短信工作。我的應用程序總是強制關閉。你能幫我嗎。這是我的代碼,其中的一部分,並且在按下按鈕並且語句正確的情況下,我需要在標記的位置發送短信。請幫忙。發送短信的應用程序將不起作用
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;
}
}
}
粘貼logcat跟蹤輸出。這可能是導致您的應用崩潰的另一件事。 –