0

I try to open Url in web browser but when I do it , the url go to Google

this is my Code :

String jokeUrl = "http://example.com/send.php?p1=" + deviceId + "&p2=" + strName + "&p3=" + Integer.toString(rate) + "&p4=";
String url = strComment;
url = url.replaceAll("\\n", "%0A");
url = url.replaceAll(" ", "%20");
jokeUrl = jokeUrl + strComment;
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(jokeUrl));
startActivity(browserIntent);

for example when I write long text , it's going to Google but when I send short text it's normally.

my TextView for strComment :

  <EditText
       android:id="@+id/etComment"
       android:layout_width="0dp"
       android:layout_height="wrap_content"
       android:layout_margin="4dp"
       android:layout_weight="1"
       android:ems="10"
       android:maxLength="300"
       android:inputType="textMultiLine"
       android:maxLines="5" />
Dici
  • 25,226
  • 7
  • 41
  • 82
programmer
  • 25
  • 8

2 Answers2

0

It's stated that URL string limit is of 2,000 characters. Check the jokeUrl size.

Log.i("Joke Url Size", jokeUrl.length() + " is the size");

For URL check this post

Community
  • 1
  • 1
Himanshu Agarwal
  • 4,623
  • 5
  • 35
  • 49
0

Consider using URLEncoder.encode() to encode all string parameters like strComment or strName.

For sending data to a backend, consider using a HTTP POST and not HTTP GET as implied by ACTION_VIEW. To send POST requests, use a HTTP stack and not an Intent like this.

laalto
  • 150,114
  • 66
  • 286
  • 303