Hi,
I have only recently begun to develop android apps. I am currently
working on a sound board, just for the learning experience more than
anything else, I have no plans to release it :). I was wondering if
anyone could help me out with setting a sound for notifications by
long clicking on a button on the sound board. I can set the buttons to
actually create a notification when clicked, and when the button is
long clicked I can create the option menu to choose a ringtone or
notification, but I don't know how to actually set a sound to these.
Any help would be greatly appreciated!
Here is a snippet of my code...
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo){
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Save as...");
menu.add(0, v.getId(), 0, "Notification");
}
public boolean onContextItemSelected(MenuItem item){
if(item.getTitle() == "Notification")
{
return true;
}
else
{
return false;
}
}
public void onLongClick(View v){
mManager
=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification();
String MyNotifyTitle = "Please work";
String MyNotifiyText = "";
Intent intent = new
Intent(getApplicationContext(),TestSoundboard.class);
intent.putExtra(MyNotifyTitle, notification.sound =
Uri.parse("android.resourse://com.testsb.TestSoundboard/" +
R.raw.are_you_crazy));
PendingIntent StartIntent =
PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
notification.setLatestEventInfo(getApplicationContext(),
MyNotifyTitle, MyNotifiyText, StartIntent);
notification.flags = notification.flags|
Notification.FLAG_ONLY_ALERT_ONCE;
mManager.notify(SIMPLE_NOTFICATION_ID, notification);
}
@Override
public void onClick(View v) {
Log.d(TAG, "onClick: " + v);
if (v.getId() == R.id.button1) {
player.start();
}
else if(v.getId() == R.id.button2){
player2.start();
}
else if (v.getId() == R.id.button3){
player3.start();
}
}
Thanks,
Ronan
--
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