views:

43

answers:

2

I have been working on c2dm for push API application. I am new to android and I dont understand the tut given at http://code.google.com/android/c2dm/index.html. Can anyone please guide me here? How would I start making an application that sends and receive the messages on emulator( I am working on emulator first and then want to test it on the device)

A: 

Alright, here is the code that I used

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mytext = (TextView) findViewById(R.id.mytext); mytext.setText("app started"); try{

    Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
    registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0)); // boilerplate
    registrationIntent.putExtra("sender", "[email protected]");
    startService(registrationIntent);

    mytext.setText("Grabbing your device registration ID.....");


}
     catch(Exception e)
     {
         mytext.setText("error in retrievening the registration id"+e);
     }
}}

Why do I get application stopped unexpectedly error. i tried to put it in the try n catch statements and even checked the logs. But no help. Anyone knows how to deal with it???

rose
A: 

Please take a look at my open source project at: http://github.com/macbuntu/Push-Contacts

Ngo Minh Nam