Issue 1061 URL-escape {CODE} replacement

git-svn-id: https://zxing.googlecode.com/svn/trunk@2034 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2011-11-14 21:22:45 +00:00
parent 157f2a2449
commit b6ac1adae2

View file

@ -62,6 +62,8 @@ import android.widget.TextView;
import android.widget.Toast;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.DateFormat;
import java.util.Collection;
import java.util.Date;
@ -578,8 +580,13 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
// with the scanned code. This allows both queries and REST-style URLs to work.
if (returnUrlTemplate != null) {
Message message = Message.obtain(handler, R.id.launch_product_query);
message.obj = returnUrlTemplate.replace(RETURN_CODE_PLACEHOLDER,
String.valueOf(resultHandler.getDisplayContents()));
String codeReplacement = String.valueOf(resultHandler.getDisplayContents());
try {
codeReplacement = URLEncoder.encode(codeReplacement, "UTF-8");
} catch (UnsupportedEncodingException e) {
// can't happen; UTF-8 is always supported. Continue, I guess, without encoding
}
message.obj = returnUrlTemplate.replace(RETURN_CODE_PLACEHOLDER, codeReplacement);
handler.sendMessageDelayed(message, INTENT_RESULT_DURATION);
}
}