相关疑难解决方法(0)

在android中以编程方式发送文本消息

好.我正在通过我的应用发送短信.发送文本消息后,它会向服务器发送状态更新.这部分工作正常,但我遇到的问题是双重的.我不确定它们是否相关,但我认为它们是相关的.

我的应用程序可以向多个用户发送单个文本.这是代码示例...

if(phoneNumbers.length > 0 && message.getText().toString().equals("") == false)
{
    for(int i=0;i<phoneNumbers.length;i++)
    {
        sms = SmsManager.getDefault();
        try
        {
            sms.sendTextMessage(phoneNumbers[i], null, message.getText().toString(), null, null);
            sentQuantity++;
        }
        catch(IllegalArgumentException e)
        {

        }
    }
}
Run Code Online (Sandbox Code Playgroud)

基本上,它只是循环遍历一组电话号码,并一次发送一个文本.这是我的问题的一部分.如果我选择3个或更多数字来发送文本,有时并不是所有文本都会被发送.它发生得非常随机.

我认为这是因为发送每条消息之间存在延迟,但代码不会等待足够长的时间.我达到了这个假设,因为如果我使用eclipse进入程序并手动浏览应用程序,一切都可以正常工作.

我的另一个问题是当我将文本消息状态更新发送到Web服务器时.

文本消息发送后,应用程序立即连接到互联网,并通过http发布服务器告知服务器发送的文本数量.这是我的互联网代码片段......

for(int i = 0; i < postNames.length; i++)
{
    nameValuePairs.add(new BasicNameValuePair(postNames[i], postValues[i]));
    }

    //http post
    try{

            HttpParams httpParameters = new BasicHttpParams();
            int timeoutConnection = 10000;

            HttpConnectionParams.setConnectionTimeout(httpParameters,timeoutConnection );

            HttpClient httpclient = new DefaultHttpClient(httpParameters);              
            HttpPost httppost = new HttpPost(webAddress);
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity …
Run Code Online (Sandbox Code Playgroud)

sms android android-intent

41
推荐指数
2
解决办法
8万
查看次数

从获取的坐标中获取位置名称

我有什么:目前我的应用程序只告诉我当前位置的坐标.

我想要的:从gps提取的坐标中获取位置名称,以便我可以知道我到底在哪里.(位置名称)

android location

17
推荐指数
3
解决办法
3万
查看次数

标签 统计

android ×2

android-intent ×1

location ×1

sms ×1