2
嗨,大家好,我想以編程方式設置設備鈴聲,但應用程序崩潰。以編程方式在Android中設置鈴聲
我使用的代碼是這樣的:
@Override
public void onClick(View v) {
Uri uri = Uri.parse("android.resource://"
+"com.ghzncl.barneystinsonsoundboard/"+R.raw.single]);
RingtoneManager.setActualDefaultRingtoneUri(
mContext, RingtoneManager.TYPE_NOTIFICATION, uri
);
// I set the data source of the mPlayer. I pass to
// the method the context and the uri of the resource.
try{
// I reset the mPlayer to its uninitialized state, in
// this way I don't need to stop the previews running quotes.
mPlayer.reset();
mPlayer.setDataSource(mContext,uri);
}catch(Exception e){
// Do Exception handling here...
}
try{
mPlayer.prepare();
}catch(Exception e){
// Do Exception handling here...
}
//The quotes start
mPlayer.start();
}
任何人都可以請幫我嗎?
什麼是例外? – CommonMan
檢查此問題http://stackoverflow.com/questions/1986756/setting-ringtone-in-android – Randroid
現在是差異我添加的權限和應用程序不會崩潰了,但鈴聲設置爲默認的Android鈴聲,而不是到我的鈴聲。爲什麼? – Nicola