Chylle
Lost but trying
Profile
Posts: 8
Reg: Aug 26, 2011
Loubajac
1,630
07/09/14 09:34 AM (10 years ago)

Push notification error resolved

file : BT_gcmConfig.java //Google GCM API Project Number (provided by google), setup in AndroidManifest.xml... // static final String SENDER_ID = getGCMProjectNumber(); static final String SENDER_ID = "3541....13564"; file : BT_gcmIntentService.java INSTEAD OF //generates actual notification... /********************************************************************************** modification Theorem-system ************************************************************************************ private static void generateNotification(Context context, String message) { BT_debugger.showIt(serviceName + ":generateNotification Message: " + message); int icon = R.drawable.icon; //title of message... String title = context.getString(R.string.app_name); //messages show in the built in notification center... Intent notificationIntent = new Intent(context, BT_activity_host.class); NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Notification.Builder builder = new Notification.Builder(cotefleuri_appDelegate.getContext()); Notification notification = new Notification(); //flag so intent does not start a new activity... notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.flags |= Notification.FLAG_AUTO_CANCEL; //play sound for notification... notification.defaults |= Notification.DEFAULT_SOUND; //vibrate if enabled... notification.defaults |= Notification.DEFAULT_VIBRATE; notificationManager.notify(0, notification); //finish builder... builder.setContentIntent(intent); builder.setSmallIcon(icon); builder.setAutoCancel(false); builder.setContentTitle(title); builder.setContentText(message); //notify... notificationManager.notify(); *********************************************************************************/ MODIFY BY private static void generateNotification(Context context, String message) { BT_debugger.showIt(serviceName + ":generateNotification Message: " + message); int icon = R.drawable.icon; int notifyID = 1; //title of message... String title = context.getString(R.string.app_name); //messages show in the built in notification center... Intent notificationIntent = new Intent(context, BT_activity_host.class); NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon,title,System.currentTimeMillis()); //flag so intent does not start a new activity... notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.flags |= Notification.FLAG_AUTO_CANCEL; //play sound for notification... notification.defaults |= Notification.DEFAULT_SOUND; //vibrate if enabled... notification.defaults |= Notification.DEFAULT_VIBRATE; notification.setLatestEventInfo(context,title, message,intent); //notify... notificationManager.notify(notifyID, notification); /******************************************************************************************************** * Fin de modification ******************************************************************************************************/ }
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
07/09/14 01:07 PM (10 years ago)
Nice!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.