cancel
Showing results for 
Search instead for 
Did you mean: 

Work Manager 6.1 for Android - Display notification pictures fetched during the transmit

Marçal_Oliveras
Active Contributor
0 Kudos

Hi,

The standard solution only gets the list of attached pictures without the content. When the user taps on one entry, a push notification is created and the user will receive the picture data later on.

But this requires to be online, so I want to fetch the notification pictures during the transmit and then be able to display them without the need of push requests.

Overriding the Notification.java object addDocumentArrayList(ArrayList<DocumentLink> linkedDocuments) method, I'm able to read each picture binary content. I created a Z BAPI, calling the already existing BAPI wrapper /SMERP/CORE_DOBDSDOCUMENT_GET and I get the content for each document link existing for each notification.

My problem is that I don't know how exactly I should store this binary data and other attributes in the Agentry DocumentLink Object in order to be able to display the picture.

Having already the basic DocumentLink properties set by the standard, I just set the picture field with the contents read from SAP with the method setPicture() in base64. Something like this:

byte[] fileDataFromBAPI = getDataAsByteArray(documentBAPI.getBinaryContent());

String fileDataInBase64 = dl.encodeBase64(fileDataFromBAPI);

dl.setPicture(fileDataInBase64);

I also modified the rules in Agentry to not create the push request for the already read document.

But when I try to open this picture, I just get the following error, is like the client is trying to access to the picture physically in the device, where it is not:

Do you have any ideas of what should I do when I store the picture data to the document link object and then how should I display the picture in the Agentry client?

Thank you in advance.

- Marçal

Accepted Solutions (1)

Accepted Solutions (1)

Marçal_Oliveras
Active Contributor
0 Kudos

Hi,

Now I've tried to just set the base64 data to the picture attribute and then in Agentry list of attachments I added a new field to display the picture, but nothing is displayed. The picture should appear under the document type and as you see there is only a blank:

Marçal_Oliveras
Active Contributor
0 Kudos

New update.

In the java code I stored the Picture to a document link string attribute with the following trick

String htmlBase64 = "<img alt=\"Embedded Image\" src=\"data:image/png;base64," +

                                   fileDataInBase64 +

                                  "\">";

Then in Agentry I created an HTML field to display the picture, and it works. But this is not a good solution because it shows the picture in fixed dimensions, it is not adapting even if the users changes from portrait to landscape, and it slows down the client (client crashed once).

But at least, now I'm 100% sure that the data coming from SAP is all right.

So my question is more clear now. How should I store the picture data in order to be able to use a an Embedded Image or Capture Image field in Agentry?

Edit: Since I didn't receive any input with a better solution I will leave this as the correct answer. I managed to redimension the image in the Java, getting the height and width and then added a smaller escalated proportions for my device screen to the html IMG tag.

Answers (0)