set sound as ringtone or notification in android app -


since, im trying learn code. decided make 1 of soundboards. since, having them on phone. i've been googling source codes of these. i've found 1 main source code of soundboard project. and, seems main 1 out there else talks about. then, wanted learn how set sound on soundboard ringtone, , notification. ive been googling hours , running same codes dont work me. can't figure out codes set sound ringtone, , or else. i've tried scratch no luck.

i can't find else on topic. please me, , im googled out find same information.

i want able program soundboard set sound ringtone or notification in android/java.

thanks.

i guess should put in code suppose. :) - know simple, giving me such hard time, , id know part. menu come up, not saving sdcard file. have no clue whats happening here in java/android. im php guy, ty help

            button btn = (button) findviewbyid(r.id.sound1);             registerforcontextmenu(btn);         }          @override         public void oncreatecontextmenu(contextmenu menu, view v,contextmenuinfo menuinfo) {         super.oncreatecontextmenu(menu, v, menuinfo);             menu.setheadertitle("set as...");             menu.add(0, v.getid(), 0, "ringtone");             menu.add(0, v.getid(), 0, "notification");         }          @override         public boolean oncontextitemselected(menuitem item) {             if(item.gettitle()=="ringtone"){function1(item.getitemid());}             else if(item.gettitle()=="notification"){function2(item.getitemid());}             else {return false;}         return true;         }          public void function1(int id){             toast.maketext(this, "ringtone saved", toast.length_short).show();         }         public void function2(int id){             toast.maketext(this, "notification saved", toast.length_short).show();         }         boolean saveas(int sound1){          byte[] buffer=null;          inputstream fin = getbasecontext().getresources().openrawresource(sound1);          int size=36462;           try {           size = fin.available();           buffer = new byte[size];           fin.read(buffer);           fin.close();          } catch (ioexception e) {           // todo auto-generated catch block           return false;          }           string path="/sdcard/media/audio/ringtones/";          string filename="sound1.ogg";           boolean exists = (new file(path)).exists();          if (!exists){new file(path).mkdirs();}           fileoutputstream save;          try {           save = new fileoutputstream(path+filename);           save.write(buffer);           save.flush();           save.close();          } catch (filenotfoundexception e) {           // todo auto-generated catch block           return false;          } catch (ioexception e) {           // todo auto-generated catch block           return false;          }               sendbroadcast(new intent(intent.action_media_scanner_scan_file, uri.parse("file://"+path+filename)));           file k = new file(path, filename);           contentvalues values = new contentvalues();          values.put(mediastore.mediacolumns.data, k.getabsolutepath());          values.put(mediastore.mediacolumns.title, "sound1");          values.put(mediastore.mediacolumns.mime_type, "audio/ogg");          values.put(mediastore.audio.media.artist, "we");          values.put(mediastore.audio.media.is_ringtone, true);          values.put(mediastore.audio.media.is_notification, true);          values.put(mediastore.audio.media.is_alarm, true);          values.put(mediastore.audio.media.is_music, false);           //insert database          this.getcontentresolver().insert(mediastore.audio.media.getcontenturiforpath(k.getabsolutepath()), values);           return false;} 

};

try converting sound file .ogg .mp3. media player isn't able play .ogg files experience. if fix should work.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -