对于不准确的标题,我不知道如何用英语表达这个概念。
我想收听并存储由任何无数字ID发送的传入短信(例如“FACEBOOK”或“VODAFONE”等。
当一个正常的合成电话号码(如555-010-101等)向我发送短信时,我通常会收听它并将其存储在手机数据库中。
好吧,似乎我不能对那些特殊的ID做同样的事情。
我的接收器就像在网络上发现的许多其他片段一样:
@Override
public void onReceive(Context context, Intent intent) {
message = "";
contactName = "";
// Get SMS map from Intent
Bundle extras = intent.getExtras();
if ( extras != null ) {
// Get received SMS array
Object[] smsExtra = (Object[]) extras.get(SMS_EXTRA_NAME);
// Get ContentResolver object for pushing encrypted SMS to incoming folder
ContentResolver contentResolver = context.getContentResolver();
assert smsExtra != null;
for (Object aSmsExtra : smsExtra) {
sms = SmsMessage.createFromPdu((byte[]) aSmsExtra);
String body = sms.getMessageBody();
address = sms.getOriginatingAddress();
message = body;
Uri uriConversation = Uri.parse("content://mms-sms/conversations/");
final String[] projection = new String[]{"*"};
final String selection = address;
Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(address));
Cursor cursor = contentResolver.query(uri, new String[]{ContactsContract.PhoneLookup.DISPLAY_NAME}, null, null, null);
// THREAD _ ID CURSOR
Cursor thread_id_cursor = contentResolver.query(
uriConversation,
projection,
selection,
null,
null
);
if (thread_id_cursor.moveToFirst()) {
thread_id = thread_id_cursor.getString(thread_id_cursor.getColumnIndexOrThrow(THREAD_ID));
}
if (cursor.moveToFirst()) {
contactName = cursor.getString(cursor.getColumnIndex(ContactsContract.PhoneLookup.DISPLAY_NAME));
}
if (contactName != null && contactName.equals("")) {
contactName = address;
}
entireMessageText.append(sms.getDisplayMessageBody());
}
// Put the sms to database
putSmsToDatabase(contentResolver, sms, entireMessageText.toString());
NotificationHandler handler = new NotificationHandler(context);
handler.build();
}
}
我认为我缺少特殊ID的东西。 任何建议都会非常感谢,提前谢谢。
答案 0 :(得分:0)
我使用此代码并正常工作
function toggleTypes(){
var el=document.getElementById('diabetes');
var medElem=document.getElementById('diabetestype');
if(el.value=='positive') {
medElem.style.display='block';
} else {
medElem.style.display='none';
}
}