在Android中我应该如何让短信发送者的电话号码吗?电话号码、短信发送、Android

由网友(烟花易逝你易变情)分享简介:在Android中我应该如何让短信发送者的电话号码吗? 我做的应用程序,发送短信,但需要钱费了,这样我可以发送短信,不收取钱?请告诉我I make application which sends sms but takes money charges for that, so can i send sms wit...

在Android中我应该如何让短信发送者的电话号码吗?

我做的应用程序,发送短信,但需要钱费了,这样我可以发送短信,不收取钱?请告诉我

I make application which sends sms but takes money charges for that, so can i send sms without charging money? please tell me

推荐答案

要发送短信不花钱,如果你执行任何免费的短信网关是唯一可能的。基于你是哪个国家,你会发现任何免费的短信网关,并试图找到他们所提供的任何Web服务或API。使用撰写code,你就可以发短信免费。使 相信这需要您的手机上的互联网连接。

To send SMS without Spending Money is only possible if you implement any FREE SMS GATEWAY. Based on what country you are, you will find any FREE SMS GATEWAY and try to find any web services or API they are providing. Write a code using that and you will be able to send SMS for FREE. Make sure this required an internet connection on your phone.

如果您实现一个广播接收器的接收短信在下面这种情况下是code将跟踪imcoming短信给你的留言和发送者号码。

If you implement a BroadCast Receiver for Incoming SMS in that case following is the code which will track your imcoming SMS and will give you the Message and Sender Number.

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.gsm.SmsMessage;
import android.widget.Toast;

public class SmsReceiver extends BroadcastReceiver
{
    @Override
    public void onReceive(Context context, Intent intent) 
    {
        //---get the SMS message passed in---
        Bundle bundle = intent.getExtras();        
        SmsMessage[] msgs = null;
        String str = "";            
        if (bundle != null)
        {
            //---retrieve the SMS message received---
            Object[] pdus = (Object[]) bundle.get("pdus");
            msgs = new SmsMessage[pdus.length];            
            for (int i=0; i<msgs.length; i++){
                msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);                
                str += "SMS from " + msgs[i].getOriginatingAddress();                     
                str += " :";
                str += msgs[i].getMessageBody().toString();
                str += "n";        
            }
            //---display the new SMS message---
            Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
        }                         
    }
}
阅读全文

相关推荐

最新文章