I am trying to develop an application to forward received SMS to a web API. I installed Go SMS, an application to handle messages in my handset. My problem is that, I am not able to run both application at a time. What will be problem?
I am using onReceive(() to handle received SMS. Is it possible to run both application at a time or is the problem within my code? If GO SMS block this, how can I do the same in my application so that my application get priority over other SMS application?
My receiver code is,
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
}
}
GO SMS disables notifications from other apps, so you don’t have two SMS apps notifying you at once. You need to instruct your users (and for yourself) to go into GO SMS and disable this feature from it’s settings.