我已经弄明白了如何发送和接收短信.要发送短信,我必须调用该类的sendTextMessage()和sendMultipartTextMessage()方法SmsManager.要接收SMS消息,我必须在AndroidMainfest.xml文件中注册接收器.然后我不得不重写onReceive()方法BroadcastReceiver.我在下面列举了一些例子.
MainActivity.java
public class MainActivity extends Activity {
private static String SENT = "SMS_SENT";
private static String DELIVERED = "SMS_DELIVERED";
private static int MAX_SMS_MESSAGE_LENGTH = 160;
// ---sends an SMS message to another device---
public static void sendSMS(String phoneNumber, String message) {
PendingIntent piSent = PendingIntent.getBroadcast(mContext, 0, new Intent(SENT), 0);
PendingIntent piDelivered = PendingIntent.getBroadcast(mContext, 0,new Intent(DELIVERED), 0);
SmsManager smsManager = SmsManager.getDefault();
int length = message.length();
if(length > MAX_SMS_MESSAGE_LENGTH) …Run Code Online (Sandbox Code Playgroud) 是否有可能在实际发送之前拦截外发短信,获取其内容然后根据某些标准忽略/发送?
例如.阻止所有国际文本(带前导00的数字),但允许其他所有内容.
您好我正在实施一个短信应用程序,现在能够检索所有消息与他们各自的联系信息,如显示名称,照片uri ..并在一个自定义列表中显示它们在项目点击带您进行相应的讨论.在这里我的问题是同步所有这些消息的时间,
这是我的代码:
ReadSMS.java:
public class ReadSMS {
ArrayList<HashMap<Contact, ArrayList<OneComment>>> recentChats;
Application _context;
public ReadSMS(Application context) {
this._context = context;
this.recentChats = ((ChatApplication) _context).getChats();
}
public ArrayList<HashMap<Contact, ArrayList<OneComment>>> getSMS() {
// Init
ArrayList<SmsMsg> smsMsgs = new ArrayList<SmsMsg>();
TreeSet<Integer> threadIds = new TreeSet<Integer>();
Uri mSmsinboxQueryUri = Uri.parse("content://sms");
Cursor cursor = _context.getContentResolver().query(
mSmsinboxQueryUri,
new String[] { "_id", "thread_id", "address", "date", "body",
"type" }, null, null, null);
String[] columns = new String[] { "address", "thread_id", "date",
"body", "type" };
if (cursor.getCount() …Run Code Online (Sandbox Code Playgroud) android android-contentresolver android-contentprovider android-contacts
我想知道是否有任何方式可以在没有互联网连接的情况下与服务器进行通信.
我认为可能通过SMS和机器可读编码.然而,这个问题证实iOS应用程序允许发送而不是阅读短信:iphone app读取短信
我也阅读了很多关于使用USSD的内容,但似乎移动打开的消息在iOS 中是不可能的(以编程方式从iphone拨打USSD代码),而在Android中可以以编程方式调用代码,没有USSD API,也没有可以静默发送USSD消息.
有没有办法在我的应用程序和我的服务器之间传输数据只有基本的语音信号?