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

  • Home
  • SEARCH
  • 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 9232205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:15:30+00:00 2026-06-18T06:15:30+00:00

I have a Servlet deployed on Google App Engine, which is playing the role

  • 0

I have a Servlet deployed on Google App Engine, which is playing the role of posting broadcast message to GCM. Android clients will receive that broadcast message from GCM. The Servlet extends BaseServlet with following snippet.

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
  //when receiving a gcm broadcast request, send message to GCM
  Builder mb = new Message.Builder();
  mb.addData("message", "The message to send");
  Message message = mb.build();
  sender.sendNoRetry(message, regIds);
  ...
}

When “the message to send” is in English, all things fine. But if “the message to send” is replaced by other language such as Chinese, the Android client will receive a string of garbled text. On Android client, I use a class extends GCMBaseIntentService to deal with GCM broadcast.

@Override
protected void onMessage(Context context, Intent intent) {

        String message = "";
        message = intent.getStringExtra("message")!=null ? intent.getStringExtra("message") : "";
        doNotify(message);
}

I have tried to re-encode the message but doesn’t work.

message = new String(message.getBytes("ISO-8859-1"), "UTF-8");

Have any idea about the problem? I need your help, Thanks.

  • 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-18T06:15:32+00:00Added an answer on June 18, 2026 at 6:15 am

    Try URLEncoder

    mb.addData("message", URLEncoder.encode("世界","UTF-8");
    

    another option:

    mb.addData("message", new StringEntity("世界", "UTF-8");
    

    After looking at the source code of GCM : com.google.android.gcm.server.Sender , it is useing HttpPost as json, and Java uses UTF-16 to internally so before you post, you will need to encode it properly.

    And as comment stated, at client decode the String

    String yourAwesomeUnicodeString=URLDecoder.decode(intent.getStringExtra("message"),"UTF-8");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got my android app that uses HttpClient to reach my servlet deployed
I have a problem with the Google App Engine JDO implementation that I cannot
I have a Play application which is deployed on Google Appengine. I use Play
I have an application which uses JSPs and Servlets and deployed on IBM-WASCE 2.1.
We have a servlet which occupies more virtual memory on the server due to
We have a servlet which occupies more virtual memory on the server as it
I have a servlet which takes us to an existing jsp, say home.jsp. This
I have a servlet in an GWT app thats creates a PDF file with
I'm using Tomcat as a servlet container, and have many WARs deployed. Many of
I have a servlet application deployed on a tomcat 7.0 server (call it Server

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.