0
我做了消息发送应用程序它的工作完美的所有版本,直到kitkat 4.4.4但不工作在棒棒糖和棉花糖我不明白为什么?消息发送代码工作到Android 4.4.4,但不工作在lolipop和marshmallo
公共无效sendsms(){
try
{
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo, null,smsmessage, null, null);
printmsg(1);
}
catch (Exception e)
{
printmsg(0);
e.printStackTrace();
}
}
public void printmsg(int a)
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Information:");
if(a==1)
builder.setMessage("SMS Send Wait For Response!!!");
else
builder.setMessage("Sending Failed, Please Try Again Later!!!");
builder.setPositiveButton("OK",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int which)
{
//Toast.makeText(getApplicationContext(), "changing activity",Toast.LENGTH_SHORT).show();
Intent intent = new Intent(ResWindow.this, Home.class);
startActivity(intent);
ResWindow.this.finish();
}
});
builder.show();
“不工作”是什么意思?你的症状是什么?例如,你崩溃了吗?如果是这样,你的堆栈跟踪是什么? – CommonsWare
添加这个 - Log.i(“Message not sent”,“”);在catch块内。 – SanVed
去在其他条件“发送失败再试一次”和消息不会和kitkat工作好消息发送工作和播种适当的消息“消息发送成功等待响应” –