Skip to main content
July 21, 2014
Question

Android Notifications help

  • July 21, 2014
  • 0 replies
  • 218 views

Has anyone here been able to successfully create a native extension for Android that creates notifications in the notification pull down menu? I have been trying over and over and cannot seem to get anything to work. I have created other fully functional native extensions, so I have the process down, but this one seems to be alluding me on getting it to work.

Here is the sample that I have been trying to use to build the test notification:

Intent intent = new Intent(extensionContext.getActivity(), extensionContext.getActivity().getClass());

PendingIntent pIntent = PendingIntent.getActivity(extensionContext.getActivity(), 0, intent, 0);


Notification mNotification = new Notification.Builder(mService)

  .setContentTitle("Hello World")

  .setContentText("content text")

  .setSmallIcon(mContext.getResourceId("drawable.btn_pause"))

  .setContentIntent(pIntent)

  .build();

mNotificationManager.notify(0, mNotification);

The biggest hang up I believe I am having is on the Intent and PendingIntent and what parameters should be going there. mService is a custom Service object which is successfully being created and Toast messages confirm that. Im not getting any errors or warnings in DDMS so that is also why I am at a loss. Im not sure if I should be putting extensionContext.getActivity().getApplication() or extensionContext.getActivity().getApplicationContext() in the parameters and have tried a variety of combinations. Any help would be appreciated.

This topic has been closed for replies.