Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7836587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:13:12+00:00 2026-06-02T14:13:12+00:00

I have a pretty simple set up for a messaging application. I simply get

  • 0

I have a pretty simple set up for a messaging application. I simply get the text from an EditText box and pass it as a parameter to a php page that adds it to my database. It works perfectly for one word entries. The moment I put in a space in the EditText box it doesn’t work. I’m still fairly new at Android. I really do not understand how this could be happening. Does anyone know how this could happen?

Here is my onClick method:

    public void sendMessage(View v) {
Log.d("tag", "XXXXXXXXXXXXXXXXXXXXXX");
        final SharedPreferences prefs = PreferenceManager
                .getDefaultSharedPreferences(getBaseContext());

        username = prefs.getString("username", "null");



where = prefs.getString("chat", "null");
        message = (EditText) findViewById(R.id.inptbox);

        function = new Functions();
        Editable messagetext;
messagetext = message.getText();


                response = function.sendMessage(username, where, messagetext.toString());
String theresponse = "";
theresponse = response;
                if (theresponse.compareTo("0") == 0) {
                    Toast.makeText(getApplicationContext(), "Success!",
                            Toast.LENGTH_SHORT).show();
                    //message.setText(null);

                } else if (response.compareTo("9") == 0) {

                    // userent.setText("nine");

                }

    }

My function.sendMessage:

    public String sendMessage(String username, String where, String string){

        BufferedReader in = null;
        String data = null;
        try{


            HttpClient client = new DefaultHttpClient();
            URI website = new URI("http://abc.com/user_send.php?username="+username+"&where="+where+"&message="+string);

            HttpPost post_request = new HttpPost();
            post_request.setURI(website);


            HttpGet request = new HttpGet();

            request.setURI(website);
            //executing actual request

                        //add your implementation here
            HttpResponse response = client.execute(request);

            in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
            StringBuffer sb = new StringBuffer("");
            String l = "";
            String nl = System.getProperty("line.separator");
            while ((l = in.readLine()) != null) {
                sb.append(l+nl);

            }
            in.close();
            data = sb.toString();


return data;
        }catch (Exception e){
            return "ERROR";

        }

        }

How should I go about solving this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T14:13:14+00:00Added an answer on June 2, 2026 at 2:13 pm

    You have to encode your message to make it “URL-safe.” Spaces (and other special characters) cannot appear in URLs; this is why your browser will replace spaces with %20 if you type them into the address bar. Try the following in function.sendMessage():

    URI website = new URI("http://abc.com/user_send.php?username="+username+"&where="+where+"&message="+URLEncoder.encode(string, "UTF-8"));
    

    Notice the use of URLEncoder at the end.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question is pretty simple: Q: Do get and set functions have an increased
I have a pretty simple JPA @ManyToMany relationship set up in my application. A
I have a pretty simple Linq to XML query: var q = from c
I have written a pretty simple code to get the first result for any
I have a pretty simple HABTM set of models class Tag < ActiveRecord::Base has_and_belongs_to_many
I have a pretty simple JSP/Servlet 3.0/Spring MVC 3.1 application. On one of my
I have a website which requires pretty simple logon restriction to a set folder
Use scenario is pretty simple: I have a desktop only application that could be
I'm building a pretty simple player and have a a buffer size set on
I'm got a pretty simple question... I have a Maven 3 project set up

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.