Android上的0级短信(flash短信)
据我所知,诺基亚和其他一些手机(如iPhone)能够发送和接收0级短信,安卓系统是否可能?Android有API吗 什么是flash短信? Flash SMS是一种短信息,到达后立即显示在手机屏幕上 除非您选择保存flash消息,否则它将在导航离开时消失,将不会保存在您的收件箱中 如果向一部手机发送多条flash信息,则只会显示最新的信息,并且会覆盖以前的所有信息 类别0:表示此消息将立即显示在MS上,并将消息传递报告发送回SC。该消息不必保存在MS或SIM卡上(除非移动用户选择保存)Android上的0级短信(flash短信),android,sms,gsm,Android,Sms,Gsm,据我所知,诺基亚和其他一些手机(如iPhone)能够发送和接收0级短信,安卓系统是否可能?Android有API吗 什么是flash短信? Flash SMS是一种短信息,到达后立即显示在手机屏幕上 除非您选择保存flash消息,否则它将在导航离开时消失,将不会保存在您的收件箱中 如果向一部手机发送多条flash信息,则只会显示最新的信息,并且会覆盖以前的所有信息 类别0:表示此消息将立即显示在MS上,并将消息传递报告发送回SC。该消息不必保存在MS或SIM卡上(除非移动用户选择保存) 是和否。
是和否。这很容易做到吗?不。从技术上讲,Tom傻瓜(阅读:反射)是可能的吗 在Android 2.2之前,可以发送Flash短信(这是0级短信的术语)。 Google删除了sendRawPdu API,因此即使使用反射,也无法做到这一点 下面是我以前是如何做的(这是在安卓1.6上测试并成功的)
对于有根的Android,可以绕过API发送0类短信。Git Hub上有一个名为: ZeroSMS是一个概念验证,演示了在android>=2.3上发送0类SMS的方法 注意:这仅适用于版本2.2->4.1.2,删除了
sendRawPdu
方法,因此您需要找到一种新的方法来执行此操作。的答案确实正确,正如ZeroSMS发送flash SMS一样;
但是,它是一个概念证明,仅支持7位编码的SMS
为了正确编码,似乎需要修改代码并添加if-then或switch-case语句:
用于7位编码,如英语
使用(字节)0xF0
对于16位编码,UCS-2编码
使用(字节)0x18
否则,如果您输入不受支持的语言,就会出现垃圾字符。好的,我会选择这个作为ans,因为它在Android 2.2之后不起作用。它在最新的Android版本上支持吗?嘿,你知道其他三个类是什么意思吗?我已经搜索了大约两个小时,但我找不到任何东西。这只适用于CyanogenMod ROM,因为它需要使用CyanogenMod证书对APK进行签名。我尝试在我的根手机上安装Zero Sms应用程序,但无论是签名的还是普通的APK,安装都失败。此零短信是否仅适用于CyanogenMod?我需要这个kitkat版本
private void sendSms(String phone, String sms) {
if ((phone == null) || (sms == null) || (phone.length() == 0)
|| (sms.length() == 0)) {
String message = "Phone or message empty!!!";
Toast notification = Toast.makeText(getBaseContext(), message,
Toast.LENGTH_SHORT);
notification.show();
return;
}
// SecurityManager oldSM = System.getSecurityManager();
// MySecurityManager newSM = new MySecurityManager();
// System.setSecurityManager(newSM);
// ServiceManager.getService("isms")
// ServiceManager.getService("isms");
SmsManager m = SmsManager.getDefault();
PendingIntent sentIntent = PendingIntent
.getBroadcast(this, 0, new Intent(
MessageStatusReceiver_MESSAGE_STATUS_RECEIVED_ACTION),
0);
PendingIntent deliveryIntent = PendingIntent.getBroadcast(this, 0,
new Intent(SmsReceiverService_MESSAGE_SENT_ACTION), 0);
// String sms = "Message self-destroyed!!!";
// String phone = "93634096";
long NOW = System.currentTimeMillis();
String time = String.valueOf(NOW);
// // m.sendTextMessage(phone, null, sms, sentIntent, deliveryIntent);
// working // m.sendTextMessage(phone, null, sms, null, null);
byte[] bb = new byte[1];
Method m2 = null;
try {
m2 = SmsManager.class.getDeclaredMethod("sendRawPdu",
bb.getClass(), bb.getClass(), PendingIntent.class,
PendingIntent.class);
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// send message
SmsMessage.SubmitPdu pdus = SmsMessage.getSubmitPdu(null, phone, sms,
false);
// http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=telephony/java/android/telephony/gsm/SmsMessage.java;h=9ccfa90d2e24e5caea26c1deac641b3c31ae56d4;hb=c883b143ba2b8bfe2f2033d00dee9ff733f1b59c
boolean submitted = false;
try {
byte[] encodedMessage = pdus.encodedMessage;
// byte[0] = mtiByte
// byte[1] = TP Message Reference
// byte[2] = length of source phone
// byte[3..length] = phone
// protocol identifier
int msgLen = encodedMessage[2] / 2;
// +2 -> length of source phone
// +2 -> for 91 after the length
// +1 -> TP PID
int indexTPDCS = msgLen + 5;
byte TPDCS = encodedMessage[indexTPDCS];
// System.out.println(TPDCS);
System.out.println(getHexString(encodedMessage));
byte[] changedMessage = encodedMessage.clone();
// Set bit 4 to 1 using OR (|), indicating there is a message class
// Set bit 0 and 1 to 0 using AND (&), indicating class 0
byte newTPDCS = (byte) ((TPDCS | 0x10) & 0xFC); // Flash SMS
changedMessage[indexTPDCS] = newTPDCS; // Class 0
System.out.println(getHexString(changedMessage));
// Log.d(SmsScheduler_TAG, getHexString(changedMessage));
boolean send = true;
if (send) {
m2.invoke(m, pdus.encodedScAddress, changedMessage, null, null);
// sendSMS(HexDump.bytesToHexString(pdus.encodedScAddress),
// HexDump.bytesToHexString(changedMessage), null);
String message = "Flash SMS sent to " + phone
+ " successfully!";
Toast notification = Toast.makeText(getBaseContext(), message,
Toast.LENGTH_SHORT);
notification.show();
Log.d(SmsScheduler_TAG, message);
submitted = true;
}
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// not essential, saves the SMS sent.
if (submitted) {
ContentValues values = new ContentValues();
values.put(ADDRESS, phone);
values.put(DATE, time);
values.put(READ, 0);
values.put(STATUS, -1);
values.put(TYPE, MESSAGE_TYPE_SENT);
values.put(BODY, sms);
Uri inserted = getContentResolver().insert(
Uri.parse("content://sms"), values);
}
// System.setSecurityManager(oldSM);
}