受信した SMS を Web API に転送するアプリケーションを開発しようとしています。ハンドセットでメッセージを処理するアプリケーションである Go SMS をインストールしました。私の問題は、一度に両方のアプリケーションを実行できないことです。何が問題になりますか?
受信した SMS を処理するために onReceive(() を使用しています。一度に両方のアプリケーションを実行することは可能ですか、それともコード内に問題がありますか? GO SMS がこれをブロックする場合、アプリケーションで同じことを行うにはどうすればよいですか?他の 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
}
}