Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4651] Android: if you add an icon to a notification the image is not found and notification is not displayed

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionInvalid
Resolution Date2012-03-07T22:04:05.000+0000
Affected Version/sRelease 1.7.1
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterJon Alter
AssigneeMarshall Culpepper
Created2011-07-13T09:46:28.000+0000
Updated2014-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();

Associated Helpdesk Ticket

http://appc.me/c/APP-634959

Comments

  1. Jon Alter 2011-09-26

    Confirmed working Example using appicon.png You can put your image in /platform/android/res/drawable/ Then reference it using Ti.App.Android.R.drawable.appicon
       var notification = Ti.Android.createNotification({
           contentIntent : pending,
           contentTitle : 'Test',
           contentText : 'test',
           when : ts,
           icon: Ti.App.Android.R.drawable.appicon
         });
       
  2. Arthur Evans 2012-03-07

    Thought this code was broken. Finally figured out how the documentation was broken.

JSON Source