Я хотел бы обратиться за помощью в отправке веб-запроса.
В части 1 я должен обнаружить определенный текст / код в смс, что сделано.
Теперь я хотел бы знать, когда обнаруживается текст / код (строка), как Android отправляет веб-запрос в веб-приложение Java?
Нужно ли использовать метод post и get?
Использование: Eclipse Indigo 2.7, API 2.3.3
Советы и любая помощь будут оценены =)
Ниже приведены мои существующие коды:
// ---get the SMS message passed in---
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
String str = "";
if (bundle != null) // if contains message
{
// ---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";
Log.i(TAG, "Message: "+msgs[i].getMessageBody().toString()); //The message content
// Checking for Pattern
// Direct use of Pattern:
Pattern p = Pattern.compile("123");
Matcher m = p.matcher(msgs[i].getMessageBody().toString());
while (m.find()) // Find each match in turn; String can't do this.
{
String result = m.group(); // Access a submatch group;
Log.i(TAG, "Password Match: " + result); //Showing the result
str +="found";
}
}
// ---display the new SMS message---
Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
}