I am attempting to implement push notifications in an Android application, and I found plenty of examples, but they all import com.google.android.gcm - a package that has since been deprecated with (supposedly) its features folded into the GooglePlayServices package (I have version 15). I've tried to hook up that as well, and it does not work with the example code, and seems to require the deprecated package.
Does anyone have any up to date examples?
Any help would be greatly appreciated in figuring this out!
I wonder why you are looking for other example while google have provided you complete working code example including both server and client. What do you need is just to check out source code from here. Import project named "gcm-client" into work space. Add "google-play-services_lib" project from android sdk folder as a library. Change your SENDER_ID in DemoActivity located in com.google.android.gcm.demo.app package. That's it.
Please ignore samples/gcm-demo-client in same downloaded code directory. It uses old deprecated classes. You may reuse its utility class ServerUtilities to send/delete registration id to/from your server. [Thanks NickT for identifying ]
Edit:
Deprecated code is still exist as gcm-client-deprecated on given repository. Just ignore it and use gcm-client.
Related
I attempted to follow and old tutorial for Sending E-mail with Amazon SES Using the AWS SDK for Android here:
https://developer.amazon.com/post/TxEUZC89WLEC2Z/Sending-E-mail-with-Amazon-SES-Using-the-AWS-SDK-for-Android.html
I am having a little trouble however. PropertyLoader cannot be resolved. What jar library is this a part of? I have tried importing all of the jar libraries from the SDK into my Eclipse project. (http://aws.amazon.com/mobile/sdk/).
I also get an error on this line: SendEmailResult result = clientManager.ses().sendEmail(request); I am guessing there is another class called ClientManager to set this up with in which I am also not able to find.
Any thoughts or links would be helpful. Thanks.
From the tutorial it looks like it follows a sample. Doing a quick Google search finds me this page.
I imagine the clientManager stuff is also there.
Note that the post is very old so I'm not even sure it still works with the current version of the SDK
I've been searching for a couple of days, including on this website. What I have found would be useful, however I find that I'm unable to follow them correctly. The questions here have no answers either.
Firstly, when I attempt to add BasegameUtils to the project and import whats needed, Eclipse cannot find them. I don't understand why, because I have imported it and marked it as a library.
This is not helped by the fact that all of the examples have their mainactivity in the folder where the API is. I have already built a full application, and I do not understand where I'm supposed to put mine.
The whole thing is incredibly confusing, and any help, or examples would be lovely.
https://developers.google.com/games/services/android/init
You need to implement baseGameUtils as a library or module depending on your IDE.
public class Main extends BaseGameActivity
And then you call this to unlock the achievement.
Games.Achievements.unlock(getApiClient(), getString(YOUR_ACHIEVEMENT_CODE));
These code samples really helped me first time round.
https://github.com/playgameservices/android-basic-samples/tree/master/BasicSamples/libraries/BaseGameUtils
The tricky part isn't the code, it's the configuration of your project, make sure to check on the play developer console that you have set up your testing account properly and your achievement codes are correct etc.
Okay, the solution was not simple. The guides seem to favour Android Studio, which implement a script to create BaseGameUtils. The BaseGameUtild that I was importing with Eclipse was not the correct one. I ended up searching for a valid one, and downloaded it.
The second thing I was doing wrong was not updating the SDK to version 20. Now, with the Play Services Lib in the extras, I could import the updated version.
After that, I discovered that gms.; actually must be written as com.google.android.gms..;. With this in line, I am now able to properly implement everything.
Thank you to those who helped.
I have strange problem with generating process. After click on Generate Cloud Endpoint Client Library everything works right, but if I look in the endpoint-libs/ folder I saw that former folder structure was changed.
First part of it is still ok endpoint-libs/libmyname-v1/myname/myname-v1-generated-source/
but next one is com/google/api/services/my.package.name/myname/ and com/google/api/services/my.package.name/myname/model/.
Despite it every single .java file of generated libraries has in my opinion wrong package:
package com.google.api.services.my.package.name.myname.model;
If anyone encountered this problem and solved it?
This is a known issue. You can see the workaround here, or follow this bug entry for status of a fix.
Google just posted GPE 3.2.3 and a server side fix which appears to correct the issue; however, existing code is not necessarily backward compatible. As an example, changes are required in the standard Google generated GCMIntentService:
Migrated to usage of the new com.google.api.services path, as:
import com.google.api.services.deviceinfoendpoint.Deviceinfoendpoint;
import com.google.api.services.deviceinfoendpoint.Deviceinfoendpoint.Builder;
import com.google.api.services.deviceinfoendpoint.model.DeviceInfo;
Modified the call to insert methods from:
endpoint.insertDeviceInfo(new com.google.api.services.deviceinfoendpoint.model.DeviceInfo().setDeviceRegistrationID(registration)).execute();
to:
endpoint.deviceInfoEndpoint().insertDeviceInfo(new com.google.api.services.deviceinfoendpoint.model.DeviceInfo().setDeviceRegistrationID(registration)).execute();
I have been unable to find the official documentation on why this breakage was required and rationale.
So I am trying to work through the example here:
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/SurfaceViewOverlay.html
and on the last import line it says
//Need the following import to get access to the app resources, since this
//class is in a sub-package.
import com.example.android.apis.R;
Question is where do I get the package that contains this? I found very little info online and obviously don't have it already since it's underlined red when I type it. I know this is probly a noob question but hey we all start somewhere...
Try to run this example using the android sample app.
To install and run the Android Sample apps follow the instructions here:
http://developer.android.com/resources/samples/get.html
To help you get started quickly, the Android SDK includes a variety of
sample code and tutorials that illustrate key concepts and techniques
of Android application development. For example, the samples show the
structure of the manifest file and the use of activities, services,
resources, intents, content providers, and permissions. They also show
how to add specialized capabilities to your apps, such as Bluetooth
and Contacts integration, multiple screens support, Live Wallpaper,
and more.
That R file is simply the R file of your project. So it will be your.project.main.package.R depending on the package attribute of the <mainfest> tag in your AndroidManifest.xml.
So if you have imported the project sample from the SDK, the R file would be in the same package as the example, i.e. com.example.android.apis.
However, if you are using the code in your own project as I assume is the case because you have mentioned the import remains unresolved, then you have to import the R file for your own project. Note that you will also have to import the required resources (layouts, drawables, etc) into your project from the sample.
In my case, I was getting this error because I needed to add the:
C:\adt-bundle-windows-x86_64-20130729\sdk\add-ons\addon-google_apis-google-18\libs\maps.jar
to the Libraries tab in the BuildPath section of "right-click over project" / Properties.
I am having some problem. When I run an console application in eclipse (non-android) I imported google-api-client-googleapis-1.4-beta.jar google-http-client-1.8.3-beta.jar
It work!!
but when I import the same thing into my android application, it fail at new com.google.api.client.http.apache.ApacheHttpTransport(); [ClassNotDef Exception]
Then I follow a lot of the post suggesting a list of library, download all of them, and import all of them.... but it still doesn't should The way I import is right click on the project->config build path -> library -> add external jar file..
So once it switch to android application, it can't find the class. I thought I import the class properly, but since I am having the classNotDef I don't think I am. Anyone knows the reason why????
Any Hints will be good.
Or maybe suggest a list of libraries require for project.
Thanks a ton.
Lawrence
The class you are looking for does not exist in Android's package structure. There are two solutions to this problem:
1: You can check out the corresponding package's documentation and use a different class.
2: On the other hand you can take the class you want and package it with your application. Then it is guaranteed that it will be found.