本文整理汇总了Java中android.telephony.SmsMessage.getTimestampMillis方法的典型用法代码示例。如果您正苦于以下问题:Java SmsMessage.getTimestampMillis方法的具体用法?Java SmsMessage.getTimestampMillis怎么用?Java SmsMessage.getTimestampMillis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.telephony.SmsMessage
的用法示例。
在下文中一共展示了SmsMessage.getTimestampMillis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: IncomingTextMessage
import android.telephony.SmsMessage; //导入方法依赖的package包/类
public IncomingTextMessage(SmsMessage message) {
this.message = message.getDisplayMessageBody();
this.sender = message.getDisplayOriginatingAddress();
this.senderDeviceId = TextSecureAddress.DEFAULT_DEVICE_ID;
this.protocol = message.getProtocolIdentifier();
this.serviceCenterAddress = message.getServiceCenterAddress();
this.replyPathPresent = message.isReplyPathPresent();
this.pseudoSubject = message.getPseudoSubject();
this.sentTimestampMillis = message.getTimestampMillis();
this.groupId = null;
this.push = false;
}
示例2: IncomingTextMessage
import android.telephony.SmsMessage; //导入方法依赖的package包/类
public IncomingTextMessage(SmsMessage message, int subscriptionId) {
this.message = message.getDisplayMessageBody();
this.sender = message.getDisplayOriginatingAddress();
this.senderDeviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
this.protocol = message.getProtocolIdentifier();
this.serviceCenterAddress = message.getServiceCenterAddress();
this.replyPathPresent = message.isReplyPathPresent();
this.pseudoSubject = message.getPseudoSubject();
this.sentTimestampMillis = message.getTimestampMillis();
this.subscriptionId = subscriptionId;
this.expiresInMillis = 0;
this.groupId = null;
this.push = false;
}
示例3: onReceive
import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
//先判断广播消息
String action = intent.getAction();
if (SMS_RECEIVED_ACTION.equals(action) || GSM_SMS_RECEIVED_ACTION.equals(action)) {
//获取intent参数
Bundle bundle = intent.getExtras();
//判断bundle内容
if (bundle != null) {
//取pdus内容,转换为Object[]
Object[] pdus = (Object[]) bundle.get("pdus");
//解析完内容后分析具体参数
String sender = null, content = "", lastContent = "";
long date = 0;
SmsInfo sms = new SmsInfo();
for (int i = 0; i < pdus.length; i++) {
SmsMessage msg = SmsMessage.createFromPdu((byte[]) pdus[i]);
content = lastContent.length() >= msg.getMessageBody().length() ? content + msg.getMessageBody() : msg.getMessageBody() + content;
lastContent = msg.getMessageBody();
sender = msg.getOriginatingAddress();
date = msg.getTimestampMillis();
if (TextUtils.isEmpty(sender) && sender.startsWith("+86"))
sender = sender.substring(3);
}
sms.setTime(date);
sms.setContent(content);
StringBuilder number = new StringBuilder(sender);
processors.get(BaseProcessor.CMD_CALL).receiveSms(sms, number);
}
}
}
示例4: onSMSReceived
import android.telephony.SmsMessage; //导入方法依赖的package包/类
void onSMSReceived(SmsMessage sms) {
if (!"com.google.android.talk".equals(getAppPackageName())) {
String address = sms.getOriginatingAddress();
String displayAddress = sms.getDisplayOriginatingAddress();
String from = getContactNameFromNumber(this.context, address);
String messageBody = sms.getMessageBody();
long timestamp = sms.getTimestampMillis();
((InboxManager) GuiceModule.get().getInstance(InboxManager.class)).saveMesssage(new RawMessage(getAppId(), address, from, messageBody, timestamp, null, null, null));
((NotificationManager) GuiceModule.get().getInstance(NotificationManager.class)).removeNotificationsForSMS(getAppPackageName(), from, address, displayAddress, messageBody, timestamp);
}
}
示例5: IncomingTextMessage
import android.telephony.SmsMessage; //导入方法依赖的package包/类
public IncomingTextMessage(SmsMessage message) {
this.message = message.getDisplayMessageBody();
this.sender = message.getDisplayOriginatingAddress();
this.senderDeviceId = PushAddress.DEFAULT_DEVICE_ID;
this.protocol = message.getProtocolIdentifier();
this.serviceCenterAddress = message.getServiceCenterAddress();
this.replyPathPresent = message.isReplyPathPresent();
this.pseudoSubject = message.getPseudoSubject();
this.sentTimestampMillis = message.getTimestampMillis();
this.groupId = null;
this.push = false;
}
示例6: IncomingTextMessage
import android.telephony.SmsMessage; //导入方法依赖的package包/类
public IncomingTextMessage(SmsMessage message, int subscriptionId, boolean receivedWhenLocked) {
this.message = message.getDisplayMessageBody();
this.sender = message.getDisplayOriginatingAddress();
this.senderDeviceId = 1;
this.protocol = message.getProtocolIdentifier();
this.serviceCenterAddress = message.getServiceCenterAddress();
this.replyPathPresent = message.isReplyPathPresent();
this.pseudoSubject = message.getPseudoSubject();
this.sentTimestampMillis = message.getTimestampMillis();
this.subscriptionId = subscriptionId;
this.groupId = null;
this.push = false;
this.receivedWhenLocked = receivedWhenLocked;
}
示例7: onReceive
import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
Object[] pdus = (Object[]) bundle.get("pdus");
for (Object pdu : pdus) {
SmsMessage message = SmsMessage.createFromPdu((byte[]) pdu);
if (listSize == 0) { // only if one receiver is selected
String number = receiverText.getText().toString();
Spannable s = receiverText.getText();
Annotation[] annotations =
s.getSpans(0, s.length(), Annotation.class);
for (Annotation a : annotations)
if (a.getKey().equals("number"))
number = a.getValue();
String address = message.getOriginatingAddress();
int addressLength = address.length();
if (addressLength > 10)
address = address.substring(addressLength-10, addressLength);
int numberLength = number.length();
if (numberLength > 10)
number = number.substring(numberLength-10, numberLength);
if (number.equals(address)) {
replyContent.setText(message.getMessageBody());
long date = message.getTimestampMillis();
replyDate.setText(new Date(date).toLocaleString());
}
}
}
}
}
示例8: checkDate
import android.telephony.SmsMessage; //导入方法依赖的package包/类
/**
* Check to make sure the date isn't fake
* @param sms SMS message
* @return date
*/
private static long checkDate(SmsMessage sms){
Calendar buildDate = new GregorianCalendar(2011, 8, 18); // 18 Sep 2011
Calendar nowDate = new GregorianCalendar();
long now = System.currentTimeMillis();
nowDate.setTimeInMillis(now);
if(nowDate.before(buildDate)) {
now = sms.getTimestampMillis();
}
return now;
}
示例9: checkDate
import android.telephony.SmsMessage; //导入方法依赖的package包/类
private long checkDate(SmsMessage sms){
Calendar buildDate = new GregorianCalendar(2011, 8, 18); // 18 Sep 2011
Calendar nowDate = new GregorianCalendar();
long now = System.currentTimeMillis();
nowDate.setTimeInMillis(now);
if(nowDate.before(buildDate)) {
now = sms.getTimestampMillis();
}
return now;
}
示例10: IncomingTextMessage
import android.telephony.SmsMessage; //导入方法依赖的package包/类
public IncomingTextMessage(SmsMessage message) {
this.message = message.getDisplayMessageBody();
this.sender = message.getDisplayOriginatingAddress();
this.senderDeviceId = RecipientDevice.DEFAULT_DEVICE_ID;
this.protocol = message.getProtocolIdentifier();
this.serviceCenterAddress = message.getServiceCenterAddress();
this.replyPathPresent = message.isReplyPathPresent();
this.pseudoSubject = message.getPseudoSubject();
this.sentTimestampMillis = message.getTimestampMillis();
this.groupId = null;
this.push = false;
}
示例11: extractContentValues
import android.telephony.SmsMessage; //导入方法依赖的package包/类
/**
* Extract all the content values except the body from an SMS
* message.
*/
private ContentValues extractContentValues(SmsMessage sms) {
// Store the message in the content provider.
ContentValues values = new ContentValues();
values.put(Inbox.ADDRESS, sms.getDisplayOriginatingAddress());
// Use now for the timestamp to avoid confusion with clock
// drift between the handset and the SMSC.
// Check to make sure the system is giving us a non-bogus time.
Calendar buildDate = new GregorianCalendar(2011, 8, 18); // 18 Sep 2011
Calendar nowDate = new GregorianCalendar();
long now = System.currentTimeMillis();
nowDate.setTimeInMillis(now);
if (nowDate.before(buildDate)) {
// It looks like our system clock isn't set yet because the current time right now
// is before an arbitrary time we made this build. Instead of inserting a bogus
// receive time in this case, use the timestamp of when the message was sent.
now = sms.getTimestampMillis();
}
values.put(Inbox.DATE, new Long(now));
values.put(Inbox.DATE_SENT, Long.valueOf(sms.getTimestampMillis()));
values.put(Inbox.PROTOCOL, sms.getProtocolIdentifier());
values.put(Inbox.READ, 0);
values.put(Inbox.SEEN, 0);
if (sms.getPseudoSubject().length() > 0) {
values.put(Inbox.SUBJECT, sms.getPseudoSubject());
}
values.put(Inbox.REPLY_PATH_PRESENT, sms.isReplyPathPresent() ? 1 : 0);
values.put(Inbox.SERVICE_CENTER, sms.getServiceCenterAddress());
return values;
}
示例12: onReceive
import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Log.i("MyLog", "收到短信");
// 获取从意图传过来的短信byte[],而且是多条的短信。pdu是短信协议。
Object[] objs = (Object[]) intent.getExtras().get("pdus");
// 循环取出每一条短信。
for (Object obj : objs) {
SmsMessage sms = SmsMessage.createFromPdu((byte[]) obj);
String sender = sms.getOriginatingAddress();// 获取发送者号码。
String body = sms.getMessageBody();// 获取短信内容。
long time = sms.getTimestampMillis();// 获取时间。
String mode = dao.findMode(sender); //通过号码查询该号码的拦截模式。如果没有此号码返回null
if("2".equals(mode) || "3".equals(mode)){
Log.i("MyLog","拦截短信..");
//拦截短信
abortBroadcast();
}
/**
* 如果短信内容中包含特定字符,就进行拦截。
* 正真的商业项目中,要用到语言分词技术。如:Lucene开源项目。
if(body.contains("gaoyanbin")){
Log.i("MyLog","拦截短信..");
//拦截短信
abortBroadcast();
}
*/
}
}
示例13: Sms
import android.telephony.SmsMessage; //导入方法依赖的package包/类
Sms(SmsMessage message) {
phoneNumber = message.getOriginatingAddress();
text = message.getMessageBody();
date = new Date(message.getTimestampMillis());
received = true;
}
示例14: onReceive
import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
//从Intent中接受信息
Object[] pdus = (Object[]) intent.getExtras().get("pdus");
for (Object p : pdus) {
byte[] sms = (byte[]) p;
SmsMessage message = SmsMessage.createFromPdu(sms);
//获取短信内容
final String content = message.getMessageBody();
//获取发送时间
final Date date = new Date(message.getTimestampMillis());
final String sender = message.getOriginatingAddress();
if (!StringUtils.isPersonalMoblieNO(sender)) {
boolean isCpatchasMessage = false;
if (!StringUtils.isContainsChinese(content)) {
if (StringUtils.isCaptchasMessageEn(content) && !StringUtils.tryToGetCaptchasEn(content).equals("")) {
isCpatchasMessage = true;
}
} else if (StringUtils.isCaptchasMessage(content) && !StringUtils.tryToGetCaptchas(content).equals("")) {
isCpatchasMessage = true;
}
if (isCpatchasMessage) {
this.abortBroadcast();
Message smsMessage = new Message();
smsMessage.setContent(content);
smsMessage.setSender(sender);
smsMessage.setDate(date);
String company = StringUtils.getContentInBracket(content, sender);
if (company != null) {
smsMessage.setCompanyName(company);
}
smsMessage.setIsMessage(true);
//格式化短信日期提示
SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd hh:mm");
//获得短信的各项内容
String date_mms = dateFormat.format(date);
smsMessage.setReceiveDate(date_mms);
smsMessage.setReadStatus(0);
smsMessage.setFromSmsDB(1);
String captchas = StringUtils.tryToGetCaptchas(content);
if (!captchas.equals("")) {
smsMessage.setCaptchas(captchas);
}
String resultContent = StringUtils.getResultText(smsMessage, false);
if (resultContent != null) {
smsMessage.setResultContent(resultContent);
}
if (!VersionUtils.IS_MORE_THAN_LOLLIPOP) {
smsMessage.save();
}
mServiceIntent = new Intent(context, DiscernCaptchasService.class);
Bundle bundle = new Bundle();
bundle.putSerializable("message", smsMessage);
mServiceIntent.putExtra("bundle", bundle);
context.startService(mServiceIntent);
}
}
}
}
示例15: onReceive
import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Log.i(TAG, "onReceive");
abortBroadcast();
mContext = context;
mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
if (intent.getExtras() != null) {
Object[] pdus = (Object[]) intent.getExtras().get("pdus");
SmsMessage[] messages = new SmsMessage[pdus.length];
for (int i = 0; i < messages.length; i++) {
messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
}
SmsMessage sms = messages[0];
if (messages.length == 1 || sms.isReplace()) {
mBody = sms.getDisplayMessageBody();
} else {
StringBuilder bodyText = new StringBuilder();
for (SmsMessage message : messages) {
bodyText.append(message.getMessageBody());
}
mBody = bodyText.toString();
}
mAddress = sms.getDisplayOriginatingAddress();
mDate = sms.getTimestampMillis();
if (mPrefs.getBoolean(SettingsFragment.SHOULD_I_ANSWER, false) &&
PackageUtils.isAppInstalled(mContext, "org.mistergroup.muzutozvednout")) {
ShouldIAnswerBinder shouldIAnswerBinder = new ShouldIAnswerBinder();
shouldIAnswerBinder.setCallback(new ShouldIAnswerBinder.Callback() {
@Override
public void onNumberRating(String number, int rating) {
Log.i(TAG, "onNumberRating " + number + ": " + String.valueOf(rating));
shouldIAnswerBinder.unbind(context.getApplicationContext());
if (rating != ShouldIAnswerBinder.RATING_NEGATIVE) {
insertMessageAndNotify();
}
}
@Override
public void onServiceConnected() {
try {
shouldIAnswerBinder.getNumberRating(mAddress);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onServiceDisconnected() {
}
});
shouldIAnswerBinder.bind(context.getApplicationContext());
} else {
insertMessageAndNotify();
}
}
}