android - Install custom notification sound with app -


i want ship custom mp3 notification sound app. want user able change notification sound different 1 , change 1 shipped using standard android notification sound picker ui. strategy copy mysound.mp3 folder named “notifications”. when manually phone automatically finds notification can picked through ui. have been able programmatically copy mysound.mp3 file res/raw folder can’t copy folder want go to. in cases can copy file directory named notifications under apps files notification sound picker ui doesn’t see there.

i new android , don’t know if apps allowed copy notifications folder. open different strategy. here code.

    inputstream in = getresources().openrawresource(r.raw.mysound);     string destdir;      //options destination directory tried didn't work     destdir = "";     destdir = "/data";     destdir = this.getexternalfilesdir(environment.directory_notifications).tostring();     destdir = this.getcachedir().tostring();     destdir = this.getfilesdir().getabsolutepath();     destdir = this.getexternalcachedir().tostring();      file mydir = new file(destdir + "/notifications");     mydir.mkdirs();      file destinationfile = new file(mydir + "/dundun.mp3");     destinationfile.delete(); //todo: delete line when copy working     boolean exists = destinationfile.exists();     if (exists) return;      fileoutputstream out = null;     try {         out =  new fileoutputstream(destinationfile.tostring());      } catch (filenotfoundexception e) {         e.printstacktrace();     }     byte[] buff = new byte[1024];     int read = 0;      try     {         while ((read = in.read(buff)) > 0) {             out.write(buff, 0, read);         }         in.close();         out.close();     }     catch (ioexception e) {     } 


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -