Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Medium
-
Resolution: Fixed
-
Affects Version/s: Release 1.7.2, Release 1.8.0
-
Fix Version/s: Release 3.0.2, Release 3.1.0, 2012 Sprint 25, 2012 Sprint 25 API
-
Component/s: Android
-
Environment:
Titanium SDK: Mobile 1.7.2, 1.8 CI Build
Platform OS: Android Version: 2.3.4
Description
Problem
If you add a sound to a notification the sound is not found.
http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Android.NotificationManager-module
Repro sequence
app.js |
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',TIMOB-4651
|
sound: '1.mp3',
|
defaults: Titanium.Android.NotificationManager.DEFAULT_VIBRATE
|
});
|
|
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();
|
Console Output - With customized Sound
Sound file is located at resources folder, so property is being set as:
sound: '1.mp3'
I/StagefrightPlayer( 34): setDataSource('/android_asset/Resources/1.mp3')
|
E/MediaPlayer( 60): error (1, -2147483648)
|
W/NotificationService( 60): error loading sound for file:///android_asset/Resources/1.mp3
|
W/NotificationService( 60): java.io.IOException: Prepare failed.: status=0x1
|
W/NotificationService( 60): at android.media.MediaPlayer.prepare(Native Method)
|
W/NotificationService( 60): at com.android.server.NotificationPlayer$CreationAndCompletionThread.run(NotificationPlayer.java:90)
|
Tested on
Device: HTC Dream Android 2.2 OS version & Emulator: Android HGVA
Associated HD ticket
PRO - http://appc.me/c/APP-923324
Additional info
Get default vibrate by setting permissions in Tiapp.xml
<android xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest>
|
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
|
</manifest>
|
</android>
|
Work Around
To allow the app at this time to play the default sound and vibration as well:
defaults: Titanium.Android.NotificationManager.DEFAULT_ALL
To play default sound:
defaults: Titanium.Android.NotificationManager.DEFAULT_SOUND
To get phone vibration:
defaults: Titanium.Android.NotificationManager.DEFAULT_VIBRATE
Attachments
Issue Links
- is cloned into
-
TIDOC-857 APIDoc: if you add a sound to a notification the sound is not found
-
- Closed
-
- relates to
-
TIMOB-11975 Android: API to expose res/raw directory
-
- Closed
-
-
TIMOB-13495 Android: HTML5 audio tag does not play in WebView
-
- Closed
-