Hi all,
i am developing a android app, where the terminal(mobile device) will
receive the notification from server whenever a failure occurs.
terminal has to alarm and displayed in notification area but it is not
happening .
The terminal is Motorola MB525 and its not happening in other devices
also.
OS is 2.2 and 2.3.
Vibrator is android.os.Vibrator
Sound android.media.MediaPlayer
It is passing through process but alarm and vibration is not happening.
(logs are correclty updated)
What could be the problem?
following is the current source
SdLog.i("");
// Generate notification manager
NotificationManager manager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
// Generate notification object
Notification notification = new
Notification(R.drawable.notification,
getString(R.string.notification_const),
System.currentTimeMillis());
notification.flags = Notification.FLAG_AUTO_CANCEL;
// vibration pattern setting
List<Long> list = new ArrayList<Long>();
list.add(0l);
for (int i = 0; i < ringTime;) {
list.add(500l);
list.add(200l);
i += 700;
}
long[] pattern = new long[list.size()];
for (int i = 0; i < list.size(); i++)
pattern[i] = list.get(i);
// notification.vibrate = array;
// notification.sound =
Settings.System.DEFAULT_NOTIFICATION_URI; //
// Default
// Uri sound = Uri.parse(ringtoneStr);
// notification.sound = sound;
// wrapped in PendingIntent the intent to issue notification
when it
is selected
// Intent intent = new Intent(this, TroubleListActivity.class);
Intent intent = new Intent(this,
TroubleNotificationService.class);
intent.setAction(getString(R.string.ACTION_TOUCH_NOTIFICATION));
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
intent, 0);
// Notification information setting
notification.setLatestEventInfo(this,
getString(R.string.notification_const), "",
contentIntent);
contentIntent = PendingIntent.getService(this, 0, intent, 0);
// Notification information setting
notification.setLatestEventInfo(this,
getString(R.string.notification_const), "",
contentIntent);
// Notification
SdLog.i("notify var.");
manager.notify(R.string.app_name, notification);
// stop notification alarm
vibrator.cancel();
stopMediaPlayer();
// restart notification alarm
mp = MediaPlayer.create(this,
Settings.System.DEFAULT_NOTIFICATION_URI);
synchronized (syncObj) {
mp.setLooping(true);
// Vibrator
AudioManager am = (AudioManager)
getSystemService(Context.AUDIO_SERVICE);
if
(am.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER) ==
AudioManager.VIBRATE_SETTING_ON) {
SdLog.i("Start vibrator.");
vibrator.vibrate(pattern, -1);
}
if (am.getRingerMode() !=
AudioManager.RINGER_MODE_SILENT) {
SdLog.i("Start sound.");
mp.start();
}
// Timer to stop alarm process
timer = new Timer(true);
timer.schedule(new TimerTask() {
public void run() {
SdLog.i("run stop timer.");
vibrator.cancel();
stopMediaPlayer();
}
}, ringTime);
}
Thanks in advance
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en