Android手机中没有两个短信应用程序同时工作

时间:2012-06-29 19:59:43

标签: android sms broadcastreceiver

我正在尝试开发一个应用程序来将收到的SMS转发到Web API。我安装了Go SMS,一个处理手机信息的应用程序。我的问题是,我无法一次运行这两个应用程序。会有什么问题?

我正在使用onReceive(()来处理收到的短信。是否可以一次运行两个应用程序或是我的代码中的问题?如果GO短信阻止这个,我怎么能在我的应用程序中做同样的事情,以便我的应用程序优先于其他SMS应用程序?

我的收件人代码是,

public void onReceive(Context context, Intent intent) {
final String telNumber="123456789";
final String message="message content comes here";
SmsManager sms= SmsManager.getDefault();
sms.sendTextMessage(telNumber, null, message, null, null);
postData(message);
}
public void postData(String url) {
    Create a new HttpClient and Post Header
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://mysite.com/index.php");

    try {
        // Add your data
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("message",url));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httppost);

    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
    } catch (IOException e) {
        // TODO Auto-generated catch block
    }
}

1 个答案:

答案 0 :(得分:0)

GO短信禁用其他应用的通知,因此您没有两个短信应用立即通知您。您需要指示您的用户(以及您自己)进入GO短信并从其设置中禁用此功能。