I am trying to set up the sample project for Worklight push notification on Android. When I launch the app in the Android emulator only the first two buttons (isSubscribed and isSupported) are clickable. The other two buttons (Subscribe and Unsubscribe) remain disabled.
My steps are:
- Import the project into Eclipse
- Replace the SenderID and API Keys with the one obtains from GCM Console in application-descriptor.xml
- Deploy the PushAdapter (included in the project)
- Build and deploy
- Launch the Android application in the emulator
What is missing?
For Push Notifications to work in the Android Emulator, you need to make sure to install in the Android SDK Manager:
The Google APIs add-on corresponding to the API Level you're using for your project (in Worklight it must be API Level 8 or above). The AVD you create should use this Google API
The Google Cloud Messaging for Android Library (available in the Extras category)
Note: Push Notifications in the Android Emulator work only in an AVD running Android OS 4.x.x.
Next, you need to set-up GCM:
These steps are relevant whether you're using a device or emulator.
- Create a Gmail email address
- Go to GCM's web page: http://developer.android.com/google/gcm/gs.html
- Click on "Google APIs Console page"
- If you have never done step 3 above, you will be asked to create a project, this project will have an ID. This ID is the
senderId
value you place in application-descriptor.xml
- Click on "Create new Server key..." / "Create new Android key"
- The generated key is the
API key
value you place in application-descriptor.xml
Now you need to:
- Build and deploy the application
- Deploy the adapter
- Run the app on a device or emulator