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 7163155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:51:16+00:00 2026-05-28T13:51:16+00:00

I have a Rails server, and I want my Java desktop application & android

  • 0

I have a Rails server, and I want my Java desktop application & android app to be able to interact with the standard scaffold (new/ edit/ show/ etc) so I can sync data between everything.

I found this (link) which shows the basic idea but not the actual code..

The catch is that the user needs to be logged in with devise, so they only see their data, not mine or yours!

Please help me regarding this.

  • 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-05-28T13:51:17+00:00Added an answer on May 28, 2026 at 1:51 pm

    JSON will better for android apps. Its lightweight than XML.

    when you are connecting to a server. each request will be webservice call to the server. you can send the authentication in the header in Base64 encoded form. so each request is parsed in the server and the credentials can be decoded and authenticated before serving the response.

    To identify the device you can send the devices IME number. you can have a table to keep track of the devices that log into your server.

    check this question for detail

    For the base64 authentication in the client side using json. i haven’t done with xml.

    public static JSONObject SendHttpPost(Context context, JSONObject jsonObjSend) {
            mPrefs = AppConfig.getPreferences(context);
            String username = mPrefs.getString("UserName","");
            String password = mPrefs.getString("Password","");
            String host = mPrefs.getString("URL","");
            String port = mPrefs.getString("Port","");
            String url = "http:\\myapp.com\controller\getuser"
    
    
        HttpResponse response = null ;
    
    
        JSONObject jsonObjRecv =null;
        try {
            String usercredential = Utility.getB64Auth(username, password);
            DefaultHttpClient httpclient = new DefaultHttpClient();
    
            HttpPost httpPostRequest = new HttpPost(url);
            StringEntity se;
            se = new StringEntity(jsonObjSend.toString());
    
            // Set HTTP parameters
            httpPostRequest.setEntity(se);
            httpPostRequest.setHeader("Authorization", usercredential);
            httpPostRequest.setHeader("Accept", "application/json");
            httpPostRequest.setHeader("Content-type", "application/json");
    
            long t = System.currentTimeMillis();
            response = (HttpResponse) httpclient.execute(httpPostRequest);
            Log.i(TAG, "HTTPResponse received in [" + (System.currentTimeMillis()-t) + "ms]");
            //Get hold of the response entity (-> the data):
            HttpEntity entity = response.getEntity();
    
            if (entity != null) {
                // Read the content stream
                InputStream instream = entity.getContent();
                Header contentEncoding = response.getFirstHeader("Content-Encoding");
                if (contentEncoding != null && contentEncoding.getValue().equalsIgnoreCase("gzip")) {
                    instream = new GZIPInputStream(instream);
                }
    
                // convert content stream to a String
                String resultString= convertStreamToString(instream);
                Log.v(null, "resultString "+resultString);
                instream.close();
    
    
                // Transform the String into a JSONObject
                if(resultString!=null){
                    jsonObjRecv = new JSONObject(resultString);
    
                }
    
                // Raw DEBUG output of our received JSON object:
                Log.i(TAG,"<jsonobject>\n"+jsonObjRecv.toString()+"\n</jsonobject>");
    
                return jsonObjRecv;
            } 
    
    
        } catch(SocketException se){
            se.printStackTrace();
    
    
        }catch (ClientProtocolException e)  {
    
            e.printStackTrace();
        } catch (IOException e) {
    
            e.printStackTrace();
        } catch (JSONException e) {
    
            e.printStackTrace();
        }
        return null;
    }
    

    Edit yes username and password pre set. use a screen like preference screen to set it. can refer json.org for parsing and creating json. yes can create nested jsons.

    JSONObject body = new JSONObject();
    JSONObject note = new JSONObject();
        JSONObject commit = new JSONObject();
         note.put("value", test2);
         commit.put("create", note);
         body.put("note", note);
         body.put("commit", commit);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Rails. I have my rails application and now I want
I have a rails application running on a Linux server. I would like to
I have a rails app that I'm moving to another server and I figure
I have a ruby on rails app running a server and sometimes it needs
I have a Ruby on Rails app running on my server, and I can't
I have a rails app running on my Apache server via Passenger. Occassionally I
I have a rails application in which I implemented some feature. Now I want
I have a Ruby/Rails app, which is standard Rails CRUD, with some jQuery and
I want my request to look and have this effect in the rails server:
I would like to have individuals config for my rails apps on my 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.