[TIMOB-4651] Android: if you add an icon to a notification the image is not found and notification is not displayed
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2012-03-07T22:04:05.000+0000 |
Affected Version/s | Release 1.7.1 |
Fix Version/s | n/a |
Components | Android |
Labels | n/a |
Reporter | Jon Alter |
Assignee | Marshall Culpepper |
Created | 2011-07-13T09:46:28.000+0000 |
Updated | 2014-06-19T12:46:30.000+0000 |
Description
If you create a notification without an 'icon' property it works fine. If you add the icon property with a path to an image you get this error.
W/TiNotification( 1099): (kroll$1: app://app.js) [1908,5174] No image found for KS_nav_ui.png
TiDocs say: the URL must be an image located in Resources/android/images/
Tested putting the image in there and in the density specific folders, but got the same error
Step 1: put an image named KS_nav_ui.png in Resources/android/images/
Step 2: run the code below
Step 3: tap the "Add Notification" button
Step 4: notice that no notification shows up and the above error is in the console log
Step 5: remove the icon property and see the notification show up.
var win= Titanium.UI.createWindow();
var btn = Ti.UI.createButton({
title: 'Add Notification'
});
btn.addEventListener('click', function(e) {
var activity = Ti.Android.currentActivity();
var intent = Ti.Android.createIntent({
});
var pending = Ti.Android.createPendingIntent({
'activity' : activity,
'intent' : intent,
'type' : Ti.Android.PENDING_INTENT_FOR_ACTIVITY,
'flags' : 1073741824
});
var ts = new Date().getTime();
var notification = Ti.Android.createNotification({
contentIntent : pending,
contentTitle : 'Test',
contentText : 'test',
when : ts,
icon: 'KS_nav_ui.png'
});
Ti.Android.NotificationManager.notify(1, notification);
});
win.add(btn);
// testing if the image exist
var lbl = Titanium.UI.createLabel({
text : ' ',
backgroundImage: 'KS_nav_ui.png',
top : 10,
left: 10
});
win.add(lbl);
win.open();
Confirmed working Example using appicon.png You can put your image in
Thought this code was broken. Finally figured out how the documentation was broken.