删除从SMSManager发送的消息 [英] Delete message sent from SMSManager
本文介绍了删除从SMSManager发送的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在安全问题上陷入困境.我正在尝试使用SMS Manager从我的Android应用发送消息,发送消息后,它将消息保存在手机的收件箱中.但是我希望消息不要以编程方式保存或删除.
I am stuck on a security issue. I am trying to send message from my android app using SMS Manager and after sending message it saves message in my Phone's inbox. But i want messages to not to be save or delete programmatically.
这是我正在使用的代码:
Here is the code which I am using:
if (ContextCompat.checkSelfPermission(Main6Activity.this,
Manifest.permission.SEND_SMS)
!= PackageManager.PERMISSION_GRANTED) {
if(ActivityCompat.shouldShowRequestPermissionRationale(Main6Activity.this,
Manifest.permission.SEND_SMS)) {
}
else {
ActivityCompat.requestPermissions(Main6Activity.this,
new String[]{Manifest.permission.SEND_SMS},
MY_PERMISSIONS_REQUEST_SEND_SMS);
}
}
else {
ActivityCompat.requestPermissions(Main6Activity.this,
new String[]{Manifest.permission.SEND_SMS},
MY_PERMISSIONS_REQUEST_SEND_SMS);
}
@Override
public void onRequestPermissionsResult(int requestCode,String permissions[],
int[] grantResults) {
switch (requestCode) {
case MY_PERMISSIONS_REQUEST_SEND_SMS: {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phone, null, "your password is
"+password, null, null);
Toast.makeText(getApplicationContext(), "SMS sent \nMake
sure you have enough balance to send message",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(),
"SMS faild, please try again.",
Toast.LENGTH_LONG).show();
return;
}
}
}
}
请帮助我.预先感谢.
推荐答案
但是我希望消息不会以编程方式保存或删除.
But i want messages to not to be save or delete programatically.
这在Android 4.4+上是不可能的.只有用户选择的SMS客户端应用程序才能修改 Sms
提供程序的内容.
This is not possible on Android 4.4+. Only the user's chosen SMS client app can modify the contents of the Sms
provider.
这篇关于删除从SMSManager发送的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文