继承我正在做的事情的代码。我点击了一个提交按钮,然后是一个警告框,其中有是/否显示确认,当你点击是时它应该发送一个文本并保存一个pdf版本。一切都有效,除了文字,并没有说它也没有发送。
submit = (Button) findViewById(R.id.button1);
submit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(shortinsp.this);
// Setting Dialog Title
alertDialog.setTitle("Submit Inspection...");
// Setting Dialog Message
alertDialog.setMessage("Are you sure you are Ready?");
// Setting Positive "Yes" Button
alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int which) {
tvstore = (TextView) findViewById(R.id.textView19);
// result = (TextView) findViewById(R.id.score);
String ph = (Config.NUMBER);
String msg = (tvstore +" short " + result);
try {
SmsManager.getDefault().sendTextMessage(ph, null, msg, null, null);
} catch (Exception e){
Toast.makeText(getApplicationContext(), "Unable to send text", Toast.LENGTH_SHORT).show();
}
printPDF();
// Write your code here to invoke YES event
// Toast.makeText(getApplicationContext(), "You clicked on YES", Toast.LENGTH_SHORT).show();
}
});
// Setting Negative "NO" Button
alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Write your code here to invoke NO event
// Toast.makeText(getApplicationContext(), "You clicked on NO", Toast.LENGTH_SHORT).show();
dialog.cancel();
}
});
// Showing Alert Message
alertDialog.show();
}
});
}
没有崩溃,printPDF按计划工作。但由于某种原因,文本永远不会发生。我有权限。我做错了什么?