user1977741
user1977741

Reputation: 1

How i make a Notification alarm sound?

How i create a simple notification alarm sound with my alarm.mp3 file?My file is inside /res/raw directory.What code i need?

   notification.sound = Uri.parse("android.resource://" +  context.getPackageName()             "/"     + R.raw.alarm );

Upvotes: 0

Views: 1459

Answers (2)

Sanket Kachhela
Sanket Kachhela

Reputation: 10856

put mp3 file in raw folder inside res. and use below code.

 notification.sound = Uri.parse("android.resource://"+context.getPackageName()+"/"+R.raw.your_sound_file_name);

Upvotes: 2

Umar Qureshi
Umar Qureshi

Reputation: 6115

you can use simply following code

notification.sound = Uri.parse("android.resource://" + this.getPackageName() + "/" + R.raw.mySound );

Upvotes: 1

Related Questions