Hi Brad,

Thanks for your response.
I followed the links you gave and was able to progress ahead.

I followed the simple concept of CloudNotes.
My is compiling fine.

I also created an application and deployed that on the App Engine.
I have a simple UI that consists of a EditText and a button. Idea is when 
the person clicks on Send button I will send the text entered to the 
DataStore.

Below is the piece of Code i m using.

I am using Emulator to test my program. Target is set to Google API 18.

The problem is that I am not able to see any error when I click Send 
button, but I am also not able to see my entities in the DataStore as 
mentioned in the last step of thie page -

https://developers.google.com/eclipse/docs/endpoints-testdeploy



package com.cloudnotes;

import java.io.IOException;
import java.util.Date;

import android.app.Activity;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

import com.cloudnotes.noteendpoint.Noteendpoint;
import com.cloudnotes.noteendpoint.model.Note;
import com.google.api.client.extensions.android.http.AndroidHttp;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.json.jackson.JacksonFactory;

public class MainActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

      //new EndpointsTask().execute(getApplicationContext());
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    
    public void sendMsg(View view) {
    EditText msgTxt = (EditText) findViewById(R.id.editText1);
    String msg = msgTxt.getText().toString();
    System.out.println("Note to be inserted - " + msg);
    
    if (msg.length() > 0){
    new EndpointsTask().execute(getApplicationContext());
    }
    }
    
    public class EndpointsTask extends AsyncTask<Context, Integer, Long> {
        protected Long doInBackground(Context... contexts) {
        System.out.println("Entered doInBackground");
          Noteendpoint.Builder endpointBuilder = new Noteendpoint.Builder(
              AndroidHttp.newCompatibleTransport(),
              new JacksonFactory(),
              new HttpRequestInitializer() {
              public void initialize(HttpRequest httpRequest) { }
              });
      Noteendpoint endpoint = CloudEndpointUtils.updateBuilder(
      endpointBuilder).build();
      try {
          Note note = new Note().setDescription("Note Description");
          String noteID = new Date().toString();
          note.setId(noteID);

          note.setEmailAddress("E-Mail Address");      
          Note result = endpoint.insertNote(note).execute();
          System.out.println("Entered doInBackground:result - "+result);
      } catch (IOException e) {
        e.printStackTrace();
      }
          return (long) 0;
        }
    }
}








On Tuesday, August 6, 2013 12:06:56 AM UTC+5:30, Brad Abrams wrote:
>
> You only need RegisterActivity for GCM support... if you are just storing 
> data then what you need to do is create some server data object (such as 
> Notes in this example) 
> https://developers.google.com/eclipse/docs/endpoints-addentities   
> Then add a Endpoint exposing it... then you can call that endpoint from 
> your MainActivity.
>
>
> But if you just want to store some simple state, I'd suggest:
>
> https://developers.google.com/cloud/samples/mbs/
>
> No server code required... 
>
>
> ..brad
>
>
> On Sun, Aug 4, 2013 at 1:16 PM, Lekh Raj <[email protected]<javascript:>
> > wrote:
>
>>
>> I have just developed a simple android application. As this is my first 
>> project I created a simple activity which has few text fields where a user 
>> can enter their values.
>>
>> Now I want to add google app engine (gae) support so that I can save 
>> these values to the gae DataStore. so I read about how to do this.
>>
>>    1. 
>>    
>>    First thing I did is to RightClick on my android project & select 
>>    google -> Generate App engine backend. This generated a few new classes 
>> for 
>>    me in my application package as I can see - - CloudEndpointsUtil.java - 
>>    GCMIntentService.java - RegisterActivity.java
>>    2. 
>>    
>>    It also generated the below classes in the folder: 
>>    
>> endpoint-libs\libdeviceinfoendpoint-v1\deviceinfoendpoint\deviceinfoendpoint-v1-generated-source
>>  
>>    package: com.xxx.deviceinfoendpoint - Deviceinfoendpoint.java - 
>>    DeviceinfoendpointRequest.java - DeviceinfoendpointRequestInitializer.java
>>    3. 
>>    
>>    It also generated the below classes in the folder: 
>>    
>> endpoint-libs\libmessageEndpoint-v1\messageEndpoint\messageendpoint-v1-generated-source
>>  
>>    package: com.xxx.messageEndpoint - MessageEndpoint.java - 
>>    MessageEndpointRequest.java - MessageEndpointRequestInitializer.java 
>>    package: com.xxx.messageEndpoint.model - 
>> CollectionResponseMessageData.java 
>>    - Key.java - MessageData.java
>>    
>> Now, my confusion is that I am kind of not able to join all the dots 
>> clearly. What I am trying to do is simple: take text values from screen & 
>> save them in the DataStore on the gae. My confusion is that has gae created 
>> this framework for me (above generated classes) which I can use to save my 
>> code. As I read we first need to create Entities, then add property/values 
>> to them and finally save that in DataStore.
>>
>> So do I have to use the above classes to save my information that I can 
>> get from my GUI or do I need to write my entity code somewhere in these 
>> classes that have been generated for me.
>>
>> I am currently working on Dev App engine server and have - 1. Changed 
>> LOCAL_ANDROID_RUN in CloudEndpointsUtil to true. 2. Gave PROJECT_NUMBER to 
>> random number "100" in GCMIntentService.
>>
>> Also do I really need to use RegisterActivity in my MainActivity onCreate 
>> for what I am trying to do.
>>
>> Any pointers will be really helpful. Thanks!
>>  
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Google App Engine" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to 
>> [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/google-appengine.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to