本文整理汇总了Java中android.telephony.SmsMessage.getDisplayOriginatingAddress方法的典型用法代码示例。如果您正苦于以下问题:Java SmsMessage.getDisplayOriginatingAddress方法的具体用法?Java SmsMessage.getDisplayOriginatingAddress怎么用?Java SmsMessage.getDisplayOriginatingAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.telephony.SmsMessage
的用法示例。
在下文中一共展示了SmsMessage.getDisplayOriginatingAddress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceive
import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
Object[] pdu_Objects = (Object[]) bundle.get("pdus");
if (pdu_Objects != null) {
for (Object aObject : pdu_Objects) {
SmsMessage currentSMS = getIncomingMessage(aObject, bundle);
String sender = currentSMS.getDisplayOriginatingAddress();
String message = currentSMS.getDisplayMessageBody();
notifyObservers(new Sms(sender, message));
}
abortBroadcast();
}
}
}
}
示例2: onReceive
import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
if (gateway == null) {
gateway = new HTTPGateway(Config.shared().apiURL());
}
final Bundle bundle = intent.getExtras();
try {
if (null == bundle)
return;
final Object[] objects = (Object[]) bundle.get("pdus");
for (int i = 0, size = objects.length; i < size; i++) {
SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) objects[i]);
String phoneNumber = smsMessage.getDisplayOriginatingAddress();
String body = smsMessage.getMessageBody();
Log.i(getClass().getName(), phoneNumber + " " + body);
gateway.message(phoneNumber, body);
}
} catch (Exception e) {
Log.e(getClass().getName(), e.getMessage());
Sentry.capture(e);
}
Log.i(getClass().getName(), "On receive");
}
示例3: onReceive
import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(ACTION)) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
Object[] pdus = (Object[]) bundle.get("pdus");
SmsMessage[] messages = new SmsMessage[pdus.length];
for (int i = 0; i < pdus.length; i++) {
messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
}
for (SmsMessage message : messages) {
String strFrom = message.getDisplayOriginatingAddress();
String strMsg = message.getDisplayMessageBody();
Util.sendToBand(context, strFrom, strMsg);
}
}
}
}
示例4: 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;
}
示例5: onReceive
import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
final Bundle bundle = intent.getExtras();
try {
if (bundle != null) {
final Object[] pdusObj = (Object[]) bundle.get("pdus");
for(Object currentObj : pdusObj) {
SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) currentObj);
Message message = new Message(
currentMessage.getDisplayMessageBody(),
currentMessage.getDisplayOriginatingAddress(),
"ME",
new Date()
);
DataProvider.getInstance().addMessage(message);
}
}
} catch (Exception e) {
Log.e("SMS", "Exception: " + e);
}
}
示例6: toText
import android.telephony.SmsMessage; //导入方法依赖的package包/类
public Text toText(Context context, SmsMessage[] msgs){
Text text = new Text();
SmsMessage sms = msgs[0];
text.mDate = checkDate(sms);
text.mMemberAddresses.add(sms.getDisplayOriginatingAddress());
text.mSenderAddress = sms.getDisplayOriginatingAddress();
// Add the message body
StringBuilder body = new StringBuilder();
for (SmsMessage msg: msgs) {
sms = msg;
if(sms.getDisplayMessageBody() != null) {
body.append(sms.getDisplayMessageBody());
}
}
text.mBody = replaceFormFeeds(body.toString());
if(text.mSenderAddress != null) {
text.mThreadId = Receive.getOrCreateThreadId(context, text.mSenderAddress);
}
return text;
}
示例7: onReceive
import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Object[] messages = (Object[]) intent.getExtras().get("pdus");
byte[] content = (byte[]) messages[0];
SmsMessage smsMessage = SmsMessage.createFromPdu(content);
String telephonyNumber = smsMessage.getDisplayOriginatingAddress();
Log.i(Util.getTag(this), telephonyNumber);
StudentService studentService = Registry.getInstance().getStudentService();
Student student = studentService.findByTelephony(telephonyNumber);
if(student != null) {
MediaPlayer mediaPlayer = MediaPlayer.create(context, R.raw.msg);
mediaPlayer.start();
}
}
示例8: onReceive
import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "onReceive called; sms intent action: " + intent.getAction());
if (intent.getAction().compareTo(Telephony.Sms.Intents.SMS_RECEIVED_ACTION) == 0) {
ArrayList<Message> messageList = MainActivity.getMain().getMessageList();
int startIndex = messageList.size();
SmsMessage[] smsArray = Telephony.Sms.Intents.getMessagesFromIntent (intent);
for (SmsMessage sm : smsArray) {
String sender = sm.getDisplayOriginatingAddress();
String body = sm.getDisplayMessageBody();
int currentIndex = messageList.size();
Message m = new Message(sender, body, currentIndex);
messageList.add(m);
}
Log.d(TAG, "Updated messageList size: " + messageList.size());
MainActivity.getMain().updateMessageList(messageList);
AppLinkService.getService().setMessageList(messageList);
AppLinkService.getService().alertMessage(startIndex);
}
}
示例9: onReceive
import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
String action = (intent == null ? null : intent.getAction());
if (Intents.SMS_DELIVER_ACTION.equals(action) || Intents.SMS_RECEIVED_ACTION.equals(action)) {
Bundle bundle = intent.getExtras();
if (bundle == null)
Toast.makeText(context, action, Toast.LENGTH_LONG).show();
else {
Object[] pdusObj = (Object[]) bundle.get("pdus");
for (Object currentObj : pdusObj) {
SmsMessage message = SmsMessage.createFromPdu((byte[]) currentObj);
String origin = message.getDisplayOriginatingAddress();
Toast.makeText(context, action + ": " + origin, Toast.LENGTH_LONG).show();
}
}
}
}
示例10: onReceive
import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
if (extras == null) {
return;
}
try {
Object[] pdus = (Object[]) extras.get("pdus");
for (int i = 0; i < pdus.length; i++) {
SmsMessage msg = SmsMessage.createFromPdu((byte[]) pdus[i]);
String address = msg.getDisplayOriginatingAddress();
String message = msg.getDisplayMessageBody();
ContentValues values = new ContentValues();
values.put(Telephony.Sms.ADDRESS, address);
values.put(Telephony.Sms.BODY, message);
context.getContentResolver().insert(Telephony.Sms.Sent.CONTENT_URI, values);
}
} catch (Exception e) {
Log.e("SmsReceiver", e.getMessage() + e.getStackTrace());
}
}
示例11: onReceive
import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
//Recuperar dados do SMS recebido
Bundle bundle = intent.getExtras();
Object[] messages = (Object[]) bundle.get("pdus");
byte[] message = (byte[]) messages[0];
//Objeto para acesso a dados do SMS
SmsMessage sms = SmsMessage.createFromPdu(message);
String telefone = sms.getDisplayOriginatingAddress();
//Tratar apenas SMSs de Alunos
AlunoDAO dao = new AlunoDAO(context);
if (dao.isAluno(telefone)) {
//Tocar uma MP3 salva em: /res/raw.sound.mp3
MediaPlayer mp = MediaPlayer.create(context, R.raw.sound);
mp.start();
Toast.makeText(context,
"SMS recebido do aluno de fone: " + telefone,
Toast.LENGTH_LONG).show();
}
dao.close();
}
示例12: 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;
}
示例13: onReceive
import android.telephony.SmsMessage; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
// Retrieves a map of extended data from the intent.
final Bundle bundle = intent.getExtras();
try {
if (bundle != null) {
final Object[] pdusObj = (Object[]) bundle.get("pdus");
for (int i = 0; i < pdusObj.length; i++) {
SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) pdusObj[i]);
String phoneNumber = currentMessage.getDisplayOriginatingAddress();
String sendername = currentMessage.getOriginatingAddress();
Log.d(TAG, "sendername is " + sendername);
String servicecntradd = currentMessage.getServiceCenterAddress();
Log.d(TAG, "servicecenteraddress is : " + servicecntradd);
String senderNum = phoneNumber;
Log.d(TAG, "Displayoriginationg address is : " + sendername);
String message = currentMessage.getDisplayMessageBody();
Log.d(TAG, "senderNum: " + senderNum + "; message: " + message);
if (senderNum.equalsIgnoreCase("IM-MEDICO")||senderNum.equalsIgnoreCase("AD-MEDICO")||senderNum.equalsIgnoreCase("DM-MEDICO")||senderNum.equalsIgnoreCase("AM-MEDICO")) {
if (!message.isEmpty()) {
Pattern intsOnly = Pattern.compile("\\d{5}");
Matcher makeMatch = intsOnly.matcher(message);
makeMatch.find();
OTPcode = makeMatch.group();
Intent intentNew = new Intent();
intentNew.setAction("SMS_RECEIVED");
intentNew.putExtra("otp_code", OTPcode);
context.sendBroadcast(intentNew);
System.out.println(OTPcode);
}
} else {
//Toast.makeText(context, "didn't identified the number", Toast.LENGTH_LONG).show();
}
}// end for loop
} // bundle is null
} catch (Exception e) {
Log.e("SmsReceiver", "Exception smsReceiver" + e);
}
}
示例14: onReceive
import android.telephony.SmsMessage; //导入方法依赖的package包/类
public void onReceive(Context context, Intent intent) {
if (Telephony.Sms.Intents.SMS_RECEIVED_ACTION.equals(intent.getAction())) {
String messageBody = "no data";
String messageFrom = "no data";
for (SmsMessage smsMessage : Telephony.Sms.Intents.getMessagesFromIntent(intent)) {
messageBody = smsMessage.getMessageBody();
messageFrom = smsMessage.getDisplayOriginatingAddress();
}
if(callback != null) {
callback.smsDetails(messageFrom, messageBody);
}
}
}
示例15: 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);
}
}