w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Google Cloud Messaging for Android library vs. Google Play Services
As far as I know, yes, the old one is deprecated (it says so here http://developer.android.com/reference/gcm-packages.html), but still works. I would recommend using the Play Services version, though, since it's MUCH easier to configure and use, and if you don't need G+ login or anything else you don't have to use it. Yes, your APK will be a little bit bigger, but I think it's worth it. Plus, any new features or improvements to the protocol will most likely be only for the Play Services library, and not for the old one.

Categories : Android

Google Play game services: socket-based messaging
I'm doing something like this too and my plan is to build a prototype with Reliable Messaging first and see how that goes. If the latency turns out to be an issue, I'll then step down to Unreliable Messaging, and then if it's really not working out, Socket-based. As with any software project, having a good architecture will allow you to switch protocols relatively painlessly. Also, there won't be any wasted work by implementing Reliable Messaging and then switching to Unreliable, since the programming required for Reliable Messaging is prerequisite for Unreliable Messaging. It'll be nice too if someone with experience could answer this question right off the bat with what will and what won't work.

Categories : Android

Can't connect to Google Cloud Messaging (GCM) server using Google App Engine (GAE)
I had the same problem and I was using something similar to what you are using. I had to enable billing on my GAE app ( which you probably have but I wasn't aware that I would have to) Read https://developers.google.com/appengine/docs/java/sockets/ and https://developers.google.com/appengine/docs/java/urlfetch/ Therefore my code which looked like yours before now looks like following: String json ="{}"; URL url = new URL("https://android.googleapis.com/gcm/send"); HTTPRequest request = new HTTPRequest(url, HTTPMethod.POST); request.addHeader(new HTTPHeader("Content-Type","application/json")); request.addHeader(new HTTPHeader("Authorization", "key=<>")); request.setPayload(json.getBytes("UTF-8")); HTTPResponse response = URLFetchServiceFactory.getURLFetchService().fetch(

Categories : Java

Error google-play-services_libAndroidManifest.xml not found or not a file with Robolectric 2 and Google Play Services (maps V2)
I have recently encountered the same problem with ActionBarSherlock when running my Robolectric tests under my Maven build plan. The problem was not evident when I was completing builds on a Windows machine and only became apparent after I switched my laptop for a OSX power device. I found that the problem was that the library name "google-play-services_lib" doesn't (exactly) match that of the folder name in the directory structure. In my case, my Eclipse project was called "ActionBarSherlock-4.3.1" whereas the folder itself was called "actionbarsherlock" under the file system. I recommend that you synchronise the two names (Eclipse project and file system) and re-run your tests. Hope that helps.

Categories : Android

new Google Cloud Messaging API
Assuming the package of the app is com.example.myexample, the following changes are required : <permission android:name="com.example.myexample.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.myexample.permission.C2D_MESSAGE" /> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="com.example.myexample" /> </intent-filter>

Categories : Android

Google Cloud Messaging Unique Key
No, the key (called Registration ID) may change after you uninstall and re-install the app. The following scenario will cause the ID to change : un-install the app send a GCM message to the device several times, until GCM server realizes that the app was uninstalled from the device re-install the app

Categories : Android

Unregister on new Google Cloud Messaging
If you are using the new GoogleCloudMessaging class, you don't need to use the com.google.android.c2dm.intent.UNREGISTER intent. Simply use GoogleCloudMessaging.unregister(). public void unregister () Unregister the application. Calling unregister() stops any messages from the server. This is a blocking call—you shouldn't call it from the UI thread. You should rarely (if ever) need to call this method. Not only is it expensive in terms of resources, but it invalidates your registration ID, which should never change unnecessarily. A better approach is to simply have your server stop sending messages. Only use unregister if you want your application to stop using GCM permanently, or you have a compelling reason to recycle your registration ID. Throws IOException if we can'

Categories : Android

Google cloud messaging, service not available
The documentation says that: When the application receives a com.google.android.c2dm.intent.REGISTRATION intent with the error extra set as SERVICE_NOT_AVAILABLE, it should retry the failed operation (register or unregister). with other words, the registration failed on GCM servers and you should retry the operation again. Make sure that you have Google Play Services installed on the device, and that you are on a stable internet connection.

Categories : Android

Google+ sign-in results in a "unknown error" - Google Play Game Services
I think the Certificate Fingerprint auto-selected by Google Play is not correct. Try deleting your app client ID on Google APIs Console, unlinked your app, then relinked it with the proper Certificate Fingerprint. The right Fingerprint is displayed when exporting your app in Eclipse.

Categories : Java

Android - Google Maps, Google Play Services library referencing
You can find the .jar file inside the libs folder of imported library(...android-sdkextrasgooglegoogle_play_serviceslibprojectgoogle-play-services_liblibs). But referencing only that jar file may be improper. I tried to do so for google maps, but didn't work. Suggested way is to import that library project to the workspace and refer the whole.

Categories : Android

Google play games services - launching the google+ sign in flow from an app in landscape mode
I can't reproduce the problem. When I set up my test app exactly as you described and hold my phone in landscape orientation, no problem happens. When I hold the phone in portrait orientation, I can see the orientation changing as the sign-in dialogs appear, and then it changes back to landscape when the app regains focus, but everything seems to be working. The auth and consent dialog appear only once, and everything seems to work fine. That said, my sample doesn't use an OpenGL canvas -- maybe that's where the problem is. Might be some weird interaction between the canvas and the sign-in flow. I would recommend hiding the OpenGL surface (and replace it with a static View that says "Signing in...") while you go through the sign-in flow, just to be sure.

Categories : Android

dependency=[com.google.android.gms:google-play-services:apklib:7:compile] not found in workspace
Finally the problem was about artifacts naming and apklib not being generated in the apk library project. This is what was wrong: The groupId and artifactId in the library pom were wrong: they must fit the name specified in the error message (I should have read it more carefully). The right values: <groupId>com.google.android.gms</groupId> <artifactId>google-play-services</artifactId> Instead of the ones generated by eclipse when converting the project to maven, which were based on the project name: <groupId>google-play-services_lib</groupId> <artifactId>google-play-services_lib</artifactId> The apklib is not generated with mvn compile, the right instruction for that is mvn package. This way the apklib file gets generated in targe

Categories : Android

Google Plus Profile Picture Google Play Game Services
The method below does what you want. public class AvatarImage extends ImageView { Bitmap image; public static final String TAG = "AvatarImage"; public AvatarImage(Context context) { super(context); setImageResource(R.drawable.avatar); } /** * This method takes the participant object and attempts to * download avatar of the participant from google plus * if this is unsuccesful default avatar is shown * @param p */ public void setImageFromParticipant(Participant p) { ImageManager im = ImageManager.create(getContext()); im.loadImage(this, p.getIconImageUri(), R.drawable.avatar); try{ Bitmap bitmap = ((BitmapDrawable)this.getDrawable()).getBitmap(); setImageBitmap(bitmap);

Categories : Eclipse

Google API Level 18 emulator "This app won't run unless you update Google Play services"
You need to setup an emulator with the API level you need + the Google API! For every API level there are 2 version of ROM! One with Google APIs and one without! If you choose the first you will be ok to run any app that uses Google Play Services!

Categories : Android

Google Plus Login : Google Play Services out of date exception
I'm also facing the same problem... I had it working about 2 weeks ago (had to format, and now i am quite upset), following Chetna answer in here: Google Play services out of date. Requires 3159100 but found 3158130 I tried to downgrade Google play services, replacing rev. 10 for 9 (rev. 9 was the version i had installed the time i got it to work - found it here: http://venomvendor.blogspot.co.il/2012/03/android-sdk-extras-by-google-inc.html), but, still no answers how to make it work! Don't understand why this question was down rated... EDIT: So, after trying for almost a day to do this, i solved my problem (and maybe yours). There are a couple of steps to take care of this: 1) Follow Chetna answer in here (2nd answer): Google Play services out of date. Requires 3159100 but found 31581

Categories : Android

Show Google Game Services support in Google Play
Implementing the Google Play Game Services features is not sufficient, your users have to use the service for you to get the badges. Let me quote from this video from Google I/O 2013: Practical Android Games Development http://youtu.be/ZbQWf7C5ymU?t=23m39s "As you get more users you will get badges. [...] However, they are not just given out because you put them in the config, and we don't snoop your APK to see if you are making API calls from there. We verify how much the feature is being used and if you meet certain threshold we give you a badge. So you need to actually integrate it, it is not a token thing that you can put there to get more eyeballs in the store."

Categories : Android

Google Cloud Messaging: BroadcastReceiver or Service?
GCM message comes as broadcast so you must use BroadcastReceiver. If you need to queue them for any reason. just make your BroadcastReceiver hand the message to IntentService or anything else you find suitable for your task.

Categories : Java

Google Cloud Messaging - server connection
Ok I encountered the same problem and I fixed it by looking for some firewall rules. Maybe you can try to add a rule to grant access from inside to gcm.googleapis.com. PS: Maybe you'll have to specify an IP instead of gcm.googleapis.com

Categories : Java

google cloud messaging in android lower than 4.1
With the old version of GCM (deprecated 1-2 month ago aprox.) you had to ask to the user to add a google account if he was running a version lower than 4.0.4 Looking at the API docs it is still a requirement Mobile Device The device that is running an Android application that uses GCM. This must be a 2.2 Android device that has Google Play Store installed, and it must have at least one logged in Google account if the device is running a version lower than Android 4.0.4. Alternatively, for testing you can use an emulator running Android 2.2 with Google APIs. GCM API I have not used the last version. If you decide to use the old one you have to generate an acces to the account settings to add an account: private String[] getAccountNames() { AccountManager accMan = A

Categories : Android

google cloud messaging errors on some devices
Quote from your manifest : <permission android:name="com.seven.carserverapp.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.gcmpush.sevenit.permission.C2D_MESSAGE" /> The permission should be YOUR_PACKAGE.permission.C2D_MESSAGE, and it should be the same in the <permission> element and the <uses-permission> element.

Categories : Android

Google Cloud Messaging single request
As a part of the GCM infrastructure, you will need to have your own web application that will allow individual instances of your app to register. When this happens, your Android application will pass to the web application a registration ID along with any additional information that you can use to identify the device. Once you have this information stored, you can pick and choose which device should receive your notification. See: Architectural Overview section in the http://developer.android.com/google/gcm/gcm.html

Categories : Java

Google Cloud Messaging registration id expiration
I am not exactly sure when GCM regId gets refreshed but, GCM Client documentation states that "Check if app was updated; if so, it must clear the registration ID, since the existing regID is not guaranteed to work with the new app version." So yes it might still be using old regId but, it's not guranteed that it will not have a new regId.

Categories : Android

Google cloud messaging by fetching from database
You have to options for this: 1.. To contact your server from the app periodically and check if there are any new notifications. If so you get the data and show it to the user. -You can do this by scheduling an alarm, maybe once a day, that starts a service that does the server checking and notifying the user. (this can be an ok solution if you know that new notifications will appear at fixed time intervals, i used it for an app that has show weekly news each Friday at noon) 2.. Google Cloud Messaging for Android Google Cloud Messaging for Android (GCM) is a service that allows you to send data from your server to your users' Android-powered device, and also to receive messages from devices on the same connection. The GCM service handles all aspects of queueing of messages and delivery

Categories : PHP

Android Google - Cloud Messaging Report
I am not sure of how to trace the confirmation but GCM Push service is not 100% reliable. There is a beautiful answer on Android GCM delivery monitoring question by @Nitin Sethi. I am quoting him here: Google does not guarantee delivery but they try for a max of 4 weeks to deliver the message. It depends on the duration that you set in the message you send to Google's GCM servers for which data would be available to them. It also depends on whether you wish to let Google keep the data for eventual delivery of message to the device, in case the device was offline when the message was to be delivered. However, there are certain conditions under which the GCM messages are not delivered: Background data is unchecked under Account and Sync settings. Prior to 4.0.4.(ICS), a Google account o

Categories : Android

Google cloud messaging starting issues
The service is no longer required. It was used with the older API. It was called by the broadcast receiver for handling arriving messages and registration results, but now all the handling of arriving messages is done in the broadcast receiver. You need a broadcast receiver class. It doesn't matter how you call it. GcmBroadcastReceiver is the class they created for the demo app. The name MyBroadcastReceiver suggests that you should create your on class. The broadcast receiver is not called from the main activity. It is called when a GCM message is sent to your app. And as for your No class def found error, assuming you're using Eclipse, you probably missed checking the Java Build Path -> Order and Export -> Android Private Libraries flag in your Android project.

Categories : Android

authenticating into Google Play Game Services on android results in error when signing in with Google Apps account
This was driving me nuts for a while. This worked for me: Log into the Developer Console Click on Game Services, then Testing Delete the tester account that's not working. Re-add the tester account. Worked right away after I did this. Hope it helps.

Categories : Android

Do I need Google+ sign-in to use Google Play Game Services?
No buttons are truly necessary, but they are the best way to communicate to the user that they can sign in with Google. If you just want to use leaderboards, here's how to do it: Perform setup and create your game's client ID as described in our docs. Configure the leaderboard in the developer console. Set up one or more test accounts to use to test your app. Once that's done you're ready to start your code. Download the samples to serve as a starting point. Import BaseGameUtils to your workspace. Import the Google Play Services library project into your workspace (you can find it in the SDK manager under Extras, Google, Google Play Services) Derive your Activity class from the sample's BaseGameActivity Add a sign-in button in your layout (see sample's layout XML) When the user click

Categories : Java

Geolocation tracking and Google Cloud Messaging working together
Yes you can do that. You will need to write a Service, you can start it on boot. You can use "Google Maps for Android API" to request one time location data using LocationClient.getLastLocation() whenever you receive GCM message. And once you have the Lcoation, you can send Lat/Lng Coordinates back into your server. You can also do reverse geocoding, geofencing and activity recognition with the API. Please be careful with users location data. Here's where you can start: Google Maps for Android API Making Location Aware App Android Services

Categories : Android

Setting up Server Side for Google Cloud Messaging
If you have used PHP you should be familiar with xampp or similar software. If not, all you have to do is download and install it, start the services and on your browser go to: http://localhost/xampp to test if it's properly installed. If you can see the Xampp page you can start running scripts php from xampp/htdocs and run them like this: http://localhost/yourscript.php Try a simple hello world: <?php echo 'hello world'; ?> After that you should be ready to start following this tutorial or any tutorial in google just typing gcm php tutorial I found that php is the most simple way for me to configure the server side for GCM, hope you find it useful...

Categories : Android

Google Cloud Messaging Unknown source exception
Most probably you are trying to register to GCM directly from the activity. But the register() method accesses the network, and like any other method that performs network operations, it should run in a separate thread otherwise an exception is thrown. The solution is to put the registration to GCM in a thread, for example in a AsyncTask, like in docs. (registerBackground() method).

Categories : Android

How to fix Google Cloud Messaging Registration error: SERVICE_NOT_AVAILABLE?
This SERVICE_NOT_AVAILABLE error says that GCM Service is not available in current. Wait and try after some time. This happens many time (As my experience), so don't worry about it. See the GCMConstants class of GCM Lib. /** * The device can't read the response, or there was a 500/503 from the * server that can be retried later. The application should use exponential * back off and retry. */ public static final String ERROR_SERVICE_NOT_AVAILABLE = "SERVICE_NOT_AVAILABLE"; For more investigation see handleRegistration() of GCMBaseIntentService private void handleRegistration(final Context context, Intent intent) { String registrationId = intent.getStringExtra(EXTRA_REGISTRATION_ID); String error = intent.getStringExtra(EXTRA_ER

Categories : Java

Activity Listener - Google Cloud Messaging - BroadcastReceiver
There are two ways to handle this. 1. Check if activity is running. ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE); List<RunningTaskInfo> taskInfo = am.getRunningTasks(1); ComponentName componentInfo = taskInfo.get(0).topActivity; if(componentInfo.getPackageName().equalsIgnoreCase("com.yourpackagename")){ //Activity Running Send a broadcast with the intent-filter which you register in your activity where you want to have the updates } else{ //Activity Not Running //Generate Notification } 2. Using SendOrderedBroadcast. This blog will give you an idea on how this could be achieved.

Categories : Android

Google cloud messaging, unable to initialize receiver
The app is looking for com.google.android.gcm.GCMBroadcastReceiver, but your class is in a different package pushNotification.GCMBroadcastReceiver. And the package of your app is a different one - com.myAppName. While your GCMBroadcastReceiver doesn't have to be in the same package as the package of your app, the category in the intent filter must be the package of the app. You should change this : <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="pushNotification" /> </intent-filter> To this : <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="com.myAppName" />

Categories : Android

How to receive messages using the new Google Cloud Messaging Api for Android?
The answer was much simpler than I thought. You no longer need gcm.jar nor gcm-server.jar. No need for a special service like GCMIntentService No need for the receiver to handle this action: com.google.android.c2dm.intent.REGISTRATION Actually a developer now needs to implement his own BroadcastReceiver which is as simple as that: in Scala class MyReceiver extends BroadcastReceiver { def onReceive(context: Context, intent: Intent) { log log "we have received something!"; val extraString = Option(intent.getStringExtra("json label here")); log log "the value of this json label is: " + extraString; } }

Categories : Android

Google Cloud Messaging send notification to all devices
Is there a way to send messages to all devices without pass the registrarions id? No way. After successfully registering on GCM, you (the Android application) should send the registration id to your application server and store them somewhere, in a database for example. This registration id will be used to send a notification to a particular device. To send a notification to all devices, would mean then to select all the registration ids from that database, and as you said, put them in an array and pass them further to GCM.

Categories : Android

Google Cloud Messaging - api keys - rebrand application
The API project id and API key are not tied to any Android app. You can even use the same API key to send notifications to different apps. Therefore you can rename your app and still use the same API project id and API key.

Categories : Android

Device Doesn't Receive message from NEW Google Cloud Messaging (NEW GCM)
Try this way UPDATE : New GCM API implementation 1) create class GcmIntentService.java public class GcmIntentService extends IntentService { public GcmIntentService() { super("your project id here"); } @Override protected void onHandleIntent(Intent intent) { // handle message here } } 2) create class GcmBroadcastReceiver.java public class GcmBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName()); context.startService((intent.setComponent(comp))); setResultCode(Activity.RESULT_OK); } } 3) Mainfest.xml pemissions for GCM <permission

Categories : Android

404 error on creation of notification_key in User Notifications in Google Cloud Messaging
It's a trial feature. You have to signup in order to test this feature : Sign up to be a trial partner for the latest Google Cloud Messaging features which include bidirectional message streaming, and user notification APIs. In the signup page you have to specify the GCM Project ID you are using to register to GCM. I assume that once you signup and your signup is approved, you'll be able to use this project ID and its API key to access the new features.

Categories : Android

google cloud messaging - xmpp server side using smack not working
The problem is resolved. The issue was indeed that the project wasn't registered. I received an email from Google 2 weeks after asking for the API receiving confirmation. The error in this case really should be improved and it would be nice if Google wrote approximately how long to receive the email. Just wanted to update anyone else encountering the problem.

Categories : Java

Is it possible for Google Cloud Messaging to remove a message from Android Notification Center?
This is exactly the use case of the new Device Group Messaging, which allows you update the state on all the users devices based on their action (i.e., dismiss on one dismisses on all others) or a server side change (your expiration).

Categories : Android



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.