Comments (9)
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.
ㅠㅠ
from gcm.
Related Issues (20)
- Issue Regarding Notification Display. HOT 1
- com.google.android.gcm.server.Sender fix ip address for gcm push notification sender
- Not receiving notification on some Custom OS after reboot
- am not able to get notification in bar when app is opened
- Message.Builder().contentAvailable(true)
- GCM and Play Services GCM
- GCM Dry run gives mismatch http post response
- I am getting below error message, while connecting the gcm through proxy org.apache.http.client.ClientProtocolException
- java.lang.NullPointerException in com.google.android.gms.gcm.GcmListenerService.zzm
- GCM Not receiving push notification in Canada
- Delete
- GCM send calls are failing -Android https://android.googleapis.com/gcm/send (push notification) HOT 1
- Don't have new release with FCM update HOT 3
- UTF-8 support is not present on Server side FCM/GCM push HOT 1
- I forgot my email id from which, i have created GCM Sender id .any way to find email id
- Delay on GCM Push Notifications sent from salesforce server.
- How to know if the requests to GCM have stopped?
- It looks like the data is there, it is just parcelled. If you try to get a particular key/value it should show up. You can always do something like intent.getStringExtra("date") before logging the Intent to force its data to unparcel.
- Not allowed to bind to service Intent HOT 2
- Security Policy violation Binary Artifacts HOT 84
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.