我正在从SMS
发送code
,同时也在更新Systems
SMS Sent
消息;与:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1)
{
int subscriptionId = SmsManager.getDefaultSmsSubscriptionId();
SmsManager MySmsManager = SmsManager.getSmsManagerForSubscriptionId(subscriptionId);
ArrayList<String> msgArray = MySmsManager.divideMessage(DefaultMsgTemplate);
MySmsManager.sendMultipartTextMessage(SendSMSTo, null,msgArray, null, null);
CurrentSmsParts = msgArray.size();
Log.d("SMS DETAILS : ", "\nFOUND LOLLIPOP MR1 OR ABOVE...");
Log.d("SMS DETAILS : ", "\nDETECTED DEFAULT SMS SIM..."+subscriptionId);
Log.d("SMS DETAILS : ", "\nSENT MSG USING SIM..."+subscriptionId);
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1)
{
SmsManager MySmsManager = SmsManager.getDefault();
ArrayList<String> msgArray = MySmsManager.divideMessage(DefaultMsgTemplate);
MySmsManager.sendMultipartTextMessage(SendSMSTo, null,msgArray, null, null);
CurrentSmsParts = msgArray.size();
Log.d("SMS DETAILS : ", "\nFOUND BELOW LOLLIPOP MR1...");
Log.d("SMS DETAILS : ", "\nDETECTED DEFAULT SMS SIM WHICHEVER AVAILABLE...");
Log.d("SMS DETAILS : ", "\nSENT MSG USING SIM1 OR SIM2 WHICHEVER IS AVAILABLE...");
}
ContentValues values = new ContentValues();
values.put("address", SendSMSTo);
values.put("body", DefaultMsgTemplate);
getContentResolver().insert(Uri.parse("content://sms/sent"), values);
SMSDone++;
这里SMSDone
是我的counter
,可以通过我的应用程序来计算today sent SMSs
...; But Users are also able to send SMSs, without my application..!!
所以..
- 如何查询SMS uri以获取两个SIM卡/号码的今天发送的短信号码?
- 我正在将我的短信插入已发送的短信;但是如何从我的应用程序中插入通过其发送SIM卡的号码?
答案 0 :(得分:0)
积分:Mike M
按照他的指示进行操作,并具有早期uri查询的基础知识,这是我实现的最终答案。...
Log.d("Executing :", "from here....\n");
try
{
Calendar c1 = Calendar.getInstance();
c1.setTime(new Date());
Calendar c2 = Calendar.getInstance();
c2.set(Calendar.YEAR, c1.get(Calendar.YEAR));
c2.set(Calendar.MONTH, c1.get(Calendar.MONTH));
c2.set(Calendar.DAY_OF_MONTH, c1.get(Calendar.DAY_OF_MONTH));
c2.set(Calendar.HOUR_OF_DAY, 0);
c2.set(Calendar.MINUTE, 0);
c2.set(Calendar.SECOND, 0);
long TodayStartedAt = c2.getTimeInMillis();
Log.d("Today started at ", "here" + TodayStartedAt);
final Uri SMS_INBOX = Uri.parse("content://sms/sent");
Cursor cursor = getContentResolver().query(SMS_INBOX, null, "date>=" + TodayStartedAt, null, null);
List < String > items = new ArrayList < String > ();
int counter = 0;
while (cursor.moveToNext())
{
String Date = cursor.getString(cursor.getColumnIndex("date"));
String SmsBody = cursor.getString(cursor.getColumnIndex("body"));
String PhoneNumber = cursor.getString(cursor.getColumnIndex("address"));
String FromSIM = cursor.getString(cursor.getColumnIndex("sub_id"));
Log.d("Counter : ", counter + "\n");
Log.d("Date : ", Date + "\n");
Log.d("PhoneNumber : ", PhoneNumber + "\n");
Log.d("FromSIM : ", FromSIM + "\n");
Log.d("SmsBody : ", SmsBody + "\n");
counter++;
}
cursor.close();
}
catch (Exception e)
{
Log.e("exception :", "is", e);
}
感谢@Mike M.并且发布,因为它将来可能会帮助其他人...