Comments (8)
The GCMConstants define a suffix for the intent service, which is appended to
your app's default package.
If you need a different class name or package, you must extend
GCMBroadcastReceiver and override the getGCMIntentServiceClassName() method to
return the desired FQCN (Fully-Qualified Class Name).
If you have an user case that is not covered by this approach, please let us
know.
Original comment by [email protected]
on 23 Jul 2012 at 4:14
- Changed state: WontFix
from gcm.
Check this code.
http://code.google.com/p/gcm/source/browse/gcm-client/src/com/google/android/gcm
/GCMRegistrar.java#285
Inside GCMRegistrar class, it uses GCMBroadcastReceiver directly.
so I think erkasrim's patch is reasonable. Is'n it?
Original comment by [email protected]
on 24 Jul 2012 at 1:56
from gcm.
Thank your answer.
I know your suggest
But!!! It is include bug!
Show this code
<GCMRegistrar class code>
public static void register(Context context, String... senderIds) {
setRetryBroadcastReceiver(context);
GCMRegistrar.resetBackoff(context);
internalRegister(context, senderIds);
}
private static synchronized void setRetryBroadcastReceiver(Context context) {
if (sRetryReceiver == null) {
sRetryReceiver = new GCMBroadcastReceiver();
String category = context.getPackageName();
IntentFilter filter = new IntentFilter(
GCMConstants.INTENT_FROM_GCM_LIBRARY_RETRY);
filter.addCategory(category);
// must use a permission that is defined on manifest for sure
String permission = category + ".permission.C2D_MESSAGE";
Log.v(TAG, "Registering receiver");
context.registerReceiver(sRetryReceiver, filter, permission, null);
}
}
register method is always call setRetryBroadcastReceiver
and setRetryBroadcastReceiver method is create the GCMBroadcastReceiver !!!
Look this is my AndroidManifest.xml file! and Custom GCMBroadcastReceiver class
I do not want define 'GCMBroadcastReceiver' in my AndroidManifest.xml file
<!-- using GCM service -->
<service android:name="net.daum.mf.push.gcm.GCMIntentService" />
<receiver
android:name="net.daum.mf.push.gcm.DaumGCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="net.daum.mf.push.sample" />
</intent-filter>
</receiver>
public class DaumGCMBroadcastReceiver extends GCMBroadcastReceiver {
private static final String TAG = "GCMBroadcastReceiver";
@Override
public final void onReceive(Context context, Intent intent) {
Log.v(TAG, "onReceive: " + intent.getAction());
String className = getGCMIntentServiceClassName(context);
Log.v(TAG, "GCM IntentService class: " + className);
// Delegates to the application-specific intent service.
GCMBaseIntentService.runIntentInService(context, intent, className);
setResult(Activity.RESULT_OK, null /* data */, null /* extra */);
}
/**
* Gets the class name of the intent service that will handle GCM messages.
*/
protected String getGCMIntentServiceClassName(Context context) {
return "net.daum.mf.push.gcm.GCMIntentService";
}
}
You know, an exception is raised!!!
And then, I need 'setGCMIntentServiceClassName' method!!!
Original comment by [email protected]
on 24 Jul 2012 at 2:18
from gcm.
GCMRegistrar uses GcmBroadcastReceiver directly because it uses it to handle
the retry logic. If you extend that class, your "main" receiver will be an
instance of the extended class, while the "retry" broadcaster will be an
instance of the base class, which is fine. Even if you don't extend it, there
will be 2 instances anyways, as they require different permissions.
So, I still don't see the point of this patch. We could split the receivers in
2 classes to make it clearer, but the overall code would be more complicated.
Original comment by [email protected]
on 24 Jul 2012 at 2:58
from gcm.
Inside 2nd instance of GCMBroadcastReceiver, it delegate intent to
DEFAULT_INTENT_SERVICE_CLASS_NAME.
if DEFAULT_INTENT_SERVICE_CLASS_NAME not exist, it will crash.
I think he want use his own service class name instead of
DEFAULT_INTENT_SERVICE_CLASS_NAME
Original comment by [email protected]
on 24 Jul 2012 at 3:41
from gcm.
Ah, ok, makes sense, thanks for the clarification.
I will try to fix it without requiring a new method.
Original comment by [email protected]
on 24 Jul 2012 at 6:15
- Changed title: GCMBroadcastReceiver.onReceive() throws exception when receiving retry intent if app uses a custom intent service class
- Changed state: Accepted
from gcm.
Fixed on
http://code.google.com/p/gcm/source/detail?r=8094cc6410b7dc2db452eb19cc9274fda1b
2d6a2 , will be available in the next release.
Please note that the new methods are used internally so this fix won't require
any change in the apps.
Original comment by [email protected]
on 27 Jul 2012 at 4:05
- Changed state: Fixed
from gcm.
Thanks~!!!
Original comment by [email protected]
on 30 Jul 2012 at 6:35
from gcm.
Related Issues (20)
- GCM with Play Services on Android on registration gets a SERVICE_NOT_AVAILABLE
- com.google.android.gcm.GCMRegistrar missing from the latest google_play_services.jar
- Patch for /gcm-client/src/com/google/android/gcm/demo/app/DemoActivity.java
- gcm push got success in server side but it is not delivered to android mobile HOT 3
- [Inquiry] In which cases do GCM server return 'NotRegistered'?
- In reality, android.permission.GET_ACCOUNTS is not needed on any OS version! HOT 1
- Unable to instantiate receiver GcmBroadcastReceiver HOT 4
- How can i get registration ID for my Nexsus?
- Missing Socket Timeout HOT 1
- support application specific GCM thottling threshold
- Cannot get registration id from GCM in restricted profile HOT 1
- message was not delivered into phone...
- Patch for /samples/gcm-demo-server/WebContent/WEB-INF/classes/api.key
- Spurious NotRegistered Error responses from GCM servers HOT 5
- Documentation for migration from C2DM needs updating for Android 5.0
- GCM not Registered Issue HOT 1
- Google Cloud Messaging (GCM) duplicates and loses some messages
- Patch for /samples/gcm-demo-client/src/com/google/android/gcm/demo/app/DemoActivity.java
- "Generate a Notification Key on the Client" results in HTTP 401 Unauthorized response HOT 3
- ANR keyDispatchingTimedOut
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gcm.