如何编写程序设置Android来电铃声

如何编写程序设置Android来电铃声,第1张

//设置--铃声的具体方法
public void setMyRingtone(String path)
{
File sdfile = new File(path);
ContentValues values = new ContentValues();
valuesput(MediaStoreMediaColumnsDATA, sdfilegetAbsolutePath());
valuesput(MediaStoreMediaColumnsTITLE, sdfilegetName());
valuesput(MediaStoreMediaColumnsMIME_TYPE, "audio/");
valuesput(MediaStoreAudioMediaIS_RINGTONE, true);
valuesput(MediaStoreAudioMediaIS_NOTIFICATION, false);
valuesput(MediaStoreAudioMediaIS_ALARM, false);
valuesput(MediaStoreAudioMediaIS_MUSIC, false);
Uri uri = MediaStoreAudioMediagetContentUriForPath(sdfilegetAbsolutePath());
Uri newUri = thisgetContentResolver()insert(uri, values);
RingtoneManagersetActualDefaultRingtoneUri(this, RingtoneManagerTYPE_RINGTONE, newUri);
ToastmakeText( getApplicationContext (),"设置来电铃声成功!", ToastLENGTH_SHORT )show();
Systemoutprintln("setMyRingtone()-----铃声");
}
//设置--提示音的具体实现方法
public void setMyNotification(String path)
{
File sdfile = new File(path);
ContentValues values = new ContentValues();
valuesput(MediaStoreMediaColumnsDATA, sdfilegetAbsolutePath());
valuesput(MediaStoreMediaColumnsTITLE, sdfilegetName());
valuesput(MediaStoreMediaColumnsMIME_TYPE, "audio/");
valuesput(MediaStoreAudioMediaIS_RINGTONE, false);
valuesput(MediaStoreAudioMediaIS_NOTIFICATION, true);
valuesput(MediaStoreAudioMediaIS_ALARM, false);
valuesput(MediaStoreAudioMediaIS_MUSIC, false);
Uri uri = MediaStoreAudioMediagetContentUriForPath(sdfilegetAbsolutePath());
Uri newUri = thisgetContentResolver()insert(uri, values);
RingtoneManagersetActualDefaultRingtoneUri(this, RingtoneManagerTYPE_NOTIFICATION, newUri);
ToastmakeText( getApplicationContext (),"设置通知铃声成功!", ToastLENGTH_SHORT )show();
Systemoutprintln("setMyNOTIFICATION-----提示音");
}
//设置--闹铃音的具体实现方法
public void setMyAlarm(String path)
{
File sdfile = new File(path);
ContentValues values = new ContentValues();
valuesput(MediaStoreMediaColumnsDATA, sdfilegetAbsolutePath());
valuesput(MediaStoreMediaColumnsTITLE, sdfilegetName());
valuesput(MediaStoreMediaColumnsMIME_TYPE, "audio/");
valuesput(MediaStoreAudioMediaIS_RINGTONE, false);
valuesput(MediaStoreAudioMediaIS_NOTIFICATION, false);
valuesput(MediaStoreAudioMediaIS_ALARM, true);
valuesput(MediaStoreAudioMediaIS_MUSIC, false);
Uri uri = MediaStoreAudioMediagetContentUriForPath(sdfilegetAbsolutePath());
Uri newUri = thisgetContentResolver()insert(uri, values);
RingtoneManagersetActualDefaultRingtoneUri(this, RingtoneManagerTYPE_ALARM, newUri);
ToastmakeText( getApplicationContext (),"设置闹钟铃声成功!", ToastLENGTH_SHORT )show();
Systemoutprintln("setMyNOTIFICATION------闹铃音");
}
2、如果读取多媒体库的音频文件,设为铃声,使用以下方式:
首先写一个常量类(定义想要设置为那种铃声的标示):
AppConstantjava
Java代码
public interface AppConstant {
public static final int RINGTONE = 0; //铃声
public static final int NOTIFICATION = 1; //通知音
public static final int ALARM = 2; //闹钟
public static final int ALL = 3; //所有声音
}
此方法需要传入想要设置为铃声的全路径(如:/mnt/sdcard/mp3/amp3),和想要设置为哪种铃声的标示:
Java代码
private void setVoice(String path2,int id)
{
ContentValues cv = new ContentValues();
Uri newUri = null;
Uri uri = MediaStoreAudioMediagetContentUriForPath(path2);
// 查询音乐文件在媒体库是否存在
Cursor cursor = thisgetContentResolver()query(uri, null, MediaStoreMediaColumnsDATA + "=", new String[] { path2 },null);
if (cursormoveToFirst() && cursorgetCount() > 0)
{
String _id = cursorgetString(0);
switch (id) {
case AppConstantRINGTONE:
cvput(MediaStoreAudioMediaIS_RINGTONE, true);
cvput(MediaStoreAudioMediaIS_NOTIFICATION, false);
cvput(MediaStoreAudioMediaIS_ALARM, false);
cvput(MediaStoreAudioMediaIS_MUSIC, false);
break;
case AppConstantNOTIFICATION:
cvput(MediaStoreAudioMediaIS_RINGTONE, false);
cvput(MediaStoreAudioMediaIS_NOTIFICATION, true);
cvput(MediaStoreAudioMediaIS_ALARM, false);
cvput(MediaStoreAudioMediaIS_MUSIC, false);
break;
case AppConstantALARM:
cvput(MediaStoreAudioMediaIS_RINGTONE, false);
cvput(MediaStoreAudioMediaIS_NOTIFICATION, false);
cvput(MediaStoreAudioMediaIS_ALARM, true);
cvput(MediaStoreAudioMediaIS_MUSIC, false);
break;
case AppConstantALL:
cvput(MediaStoreAudioMediaIS_RINGTONE, true);
cvput(MediaStoreAudioMediaIS_NOTIFICATION, true);
cvput(MediaStoreAudioMediaIS_ALARM, true);
cvput(MediaStoreAudioMediaIS_MUSIC, false);
break;
default:
break;
}
// 把需要设为铃声的歌曲更新铃声库
getContentResolver()update(uri, cv, MediaStoreMediaColumnsDATA + "=",new String[] { path2 });
newUri = ContentUriswithAppendedId(uri, LongvalueOf(_id));
// 一下为关键代码:
switch (id) {
case AppConstantRINGTONE:
RingtoneManagersetActualDefaultRingtoneUri(this, RingtoneManagerTYPE_RINGTONE, newUri);
break;
case AppConstantNOTIFICATION:
RingtoneManagersetActualDefaultRingtoneUri(this, RingtoneManagerTYPE_NOTIFICATION, newUri);
break;
case AppConstantALARM:
RingtoneManagersetActualDefaultRingtoneUri(this, RingtoneManagerTYPE_ALARM, newUri);
break;
case AppConstantALL:
RingtoneManagersetActualDefaultRingtoneUri(this, RingtoneManagerTYPE_ALL, newUri);
break;
default:
break;
}
//播放铃声
//Ringtone rt = RingtoneManagergetRingtone(this, newUri);
//rtplay();
}
}

IT168技术对于Android应用开发来说,手机铃声是一个非常重要的需求,网上查了很多例子,都有点问题,综合几个自己写了个可以设置铃声、通知声音、闹钟声音和所有声音功能的方法。
首先写一个常量类(定义想要设置为那种铃声的标示):
AppConstantjava
public interface AppConstant {
public static final int RINGTONE = 0; //铃声
public static final int NOTIFICATION = 1; //通知音
public static final int ALARM = 2; //闹钟
public static final int ALL = 3; //所有声音
此方法需要传入想要设置为铃声的全路径(如:/mnt/sdcard/mp3/amp3 ),和想要设置为那种铃声的标示:
private void setVoice(String path2,int id)
2
3 {
4
5 ContentValues cv = new ContentValues();
6
7 Uri newUri = null;
8
9 Uri uri = MediaStoreAudioMediagetContentUriForPath(path2);
10
11 // 查询音乐文件在媒体库是否存在
12
13 Cursor cursor = thisgetContentResolver()query(uri, null, MediaStoreMediaColumnsDATA + =, new String[] { path2 },null);
14
15 if (cursormoveToFirst() && cursorgetCount() > 0)
16
17 {
18
19 String _id = cursorgetString(0);
20
21 switch (id) {
22
23 case AppConstantRINGTONE:
24
25 cvput(MediaStoreAudioMediaIS_RINGTONE, true);
26
27 cvput(MediaStoreAudioMediaIS_NOTIFICATION, false);
28
29 cvput(MediaStoreAudioMediaIS_ALARM, false);
30
31 cvput(MediaStoreAudioMediaIS_MUSIC, false);
32
33 break;
34
35 case AppConstantNOTIFICATION:
36
37 cvput(MediaStoreAudioMediaIS_RINGTONE, false);
38
39 cvput(MediaStoreAudioMediaIS_NOTIFICATION, true);
40
41 cvput(MediaStoreAudioMediaIS_ALARM, false);
42
43 cvput(MediaStoreAudioMediaIS_MUSIC, false);
44
45 break;
46
47 case AppConstantALARM:
48
49 cvput(MediaStoreAudioMediaIS_RINGTONE, false);
50
51 cvput(MediaStoreAudioMediaIS_NOTIFICATION, false);
52
53 cvput(MediaStoreAudioMediaIS_ALARM, true);
54
55 cvput(MediaStoreAudioMediaIS_MUSIC, false);
56
57 break;
58
59 case AppConstantALL:
60
61 cvput(MediaStoreAudioMediaIS_RINGTONE, true);
62
63 cvput(MediaStoreAudioMediaIS_NOTIFICATION, true);
64
65 cvput(MediaStoreAudioMediaIS_ALARM, true);
66
67 cvput(MediaStoreAudioMediaIS_MUSIC, false);
68
69 break;
70
71
72
73 default:
74
75 break;
76
77 }
78
79
80
81 // 把需要设为铃声的歌曲更新铃声库
82
83 getContentResolver()update(uri, cv, MediaStoreMediaColumnsDATA + =,new String[] { path2 });
84
86
87
88
89 // 一下为关键代码:
90
91 switch (id) {
92
93 case AppConstantRINGTONE:
94
95 RingtoneManagersetActualDefaultRingtoneUri(this, RingtoneManagerTYPE_RINGTONE, newUri);
96
97 break;
98
99 case AppConstantNOTIFICATION:
100
101 RingtoneManagersetActualDefaultRingtoneUri(this, RingtoneManagerTYPE_NOTIFICATION, newUri);
102
103 break;
104
105 case AppConstantALARM:
106
107 RingtoneManagersetActualDefaultRingtoneUri(this, RingtoneManagerTYPE_ALARM, newUri);
108
109 break;
110
111 case AppConstantALL:
112
113 RingtoneManagersetActualDefaultRingtoneUri(this, RingtoneManagerTYPE_ALL, newUri);
114
115 break;
116
117
118
119 default:
120
121 break;
122
123 }
124
125
126
127 //播放铃声
129 // Ringtone rt = RingtoneManagergetRingtone(this, newUri);
131 // rtplay();
133 }
135 }

Mobile Ringtone Converter(手机铃声超强转换工具) 239 汉化绿色版
>Eric Church, Hell On The Heart
Artist: Church Eric
Song: Hell On The Heart
Album: Carolina
Eric Church Sheet Music
Eric Church CDs
Download RingtoneSend “Hell On The Heart” Ringtone to Cell PhoneDownload Ringtone
No if, and's, but's or maybe's
So you wanna be her baby
I can read your face like a book
Yeah it looks easy to love her but believe me brother
It's harder than it looks
She's as pretty as a picture
Every bit as funny as she is smart
Got a smile that'll hold you together
And a touch that'll tear you apart
When she's yours she brings the sunshine
When she's gone the world goes dark
Yeah she's heaven on the eyes
But boy she's hell on the heart
Yeah she's good when she's bad
She's cute when she's mad
And she does all the wrong things right
Yeah boy it's a fact when they're made like that
You ain't ever gonna sleep at night
She's as pretty as a picture
Every bit as funny as she is smart
Got a smile that'll hold you together
And a touch that'll tear you apart
When she's yours she brings the sunshine
When she's gone the world goes dark
Yeah she's heaven on the eyes
But boy she's hell on the heart
Once you feel her touch and you've felt that rush
It's gonna mess up your head
But here's the kicker son
Your old ticker's gonna beat you half to death
She's as pretty as a picture
Every bit as funny as she is smart
Got a smile that'll hold you together
And a touch that'll tear you apart
When she's yours she brings the sunshine
When she's gone the world goes dark
Yeah she's heaven on the eyes
But boy she's hell on the heart
Yeah she's hell on the heart

英文:
right thurr
歌手:chingy
CHINGY LYRICS
"Right Thurr"
uh ey dirty (what)
look at that girl right there (aw)
she make me faint (ohh)
ohhh oh oh
do whatchu do
I like the way you do that right thurr (right thurr)
Swish your hips when you walk, let down your hair (down your hurr)
I like the what you do that right thurr (right thurr)
wet your lips when you talk,that make me slurr (make me slurr)
I like the way you look in them pants, say you fine (fine)
your mama a quarter peice, she far from a dime (dime)
The type of girl that will getchu up and go make you grind (grind)
I'm thinkin bout snatchn' her up
Dirty, making her mine
Look at her hips, look at her legs, Ain't she stacked (stacked)
I sure wouldn't mind hittn' that from the back (back)
I like it when I touch it, cuz she moan lil bit
Jeans saggin', so I can see her thong lil bit
I know she grown lil bit, 20 years old, you legal
Don't trip off my people, just hop in the regal
I swoop on her like an eagle, swoop down and rate
I know your popular, but you gon be famous today
I like the way you do that right thurr (right thurr)
Swish your hips when you walk, let down your hair (down your hurr)
I like the what you do that right thurr (right thurr)
wet your lips when you talk,that make me slurr (make me slurr)
I like the way you do that right thurr (right thurr)
Swish your hips when you walk, let down your hair (down your hurr)
I like the what you do that right thurr (right thurr)
wet your lips when you talk,that make me slurr (make me slurr)
She be shoppin at front nack, just look at her front back
Man she's soo stacked, does she knows that I want that
He make he's soo whack, girl can i taste your cat
Gave her 300$ to spend, like buying a throw-back
She stay in the club, like they be saying she got it
In real life, girl remind me of pochantas
She be at events, like the best when she past
All the high rollin' cats, wana pay for that ssss
Niggas half steppin', strapped with a nice weapon
It's against the law for her to move them hips
If you ever seen it dirty, your mouth gone drop
World wide, fools volenteer tell you its off top
I like the way you do that right thurr (right thurr)
Swish your hips when you walk, let down your hair (down your hurr)
I like the what you do that right thurr (right thurr)
wet your lips when you talk,that make me slurr (make me slurr)
I like the way you do that right thurr (right thurr)
Swish your hips when you walk, let down your hair (down your hurr)
I like the what you do that right thurr (right thurr)
wet your lips when you talk,that make me slurr (make me slurr)
I like it when she's doing that (come on)
Cuz I like it when she bring it back
ohhh ohhh ohhh ohhh do what you do
I like it when she's doing that (uhhh)
Cuz I like it when she bring it back
ohhh ohhh ohhh ohhh do what you do
Gimmie what you got for a pork chop (uh)
She threw it at me like I was a show stop (uh)
Twerkin in a phatty girl halter top
Then she backed it up on me, and let it drop (drop)
Make it hop (boing) , like a bunny (bunny)
Can I touch you where it's sunny
Or embarrass, and make you give us some money
She should pose for sports illustriated
It's like a picture perfect site
when she passed all the other girls hated
But I like the way you do that right thurr (right thurr)
Swish your hips when you walk, let down your hair (down your hurr)
I like the what you do that right thurr (right thurr)
wet your lips when you talk,that make me slurr (make me slurr)
I like the way you do that right thurr (right thurr)
Swish your hips when you walk, let down your hair (down your hurr)
I like the what you do that right thurr (right thurr)
wet your lips when you talk,that make me slurr (make me slurr)
I like that
I like that
I like that
I like that oh oh oh
I like that
I like that
I like that
I like that oh oh oh
中文:
正确的 thurr 打印此页
歌手: chingy
CHINGY 抒情诗
"正确的 Thurr"
肮脏的 uh ey(什么)
就在那里看着那个少女 (aw)
使我昏倒 (ohh)
ohhh 表示惊讶表示惊讶
whatchu 做吗
我喜欢你所做的方式正确的 thurr(正确的 thurr)
当你走路的时候 , 发飕飕声你的臀部, 感到失望的你头发 (下你的 hurr 置于地面)
我喜欢那你做正确的 thurr 什么 (正确的 thurr)
变湿你的唇当你说话的时候, 那使我成为 slurr(使我成为 slurr)
我喜欢你顺便探访他们裤子的方式, 说你罚款 (罚款)
你的妈妈四分之一 peice, 她离一个一角硬币很远 (一角硬币)
少女的类型将会 getchu 向上而且去使你磨擦 (磨)
我是 thinkin 次 snatchn' 她向上
肮脏的,使她挖掘
看着她的臀部,看着她的腿, 不是她被堆积 (堆积)
我当然不留意 hittn' 从背面 (背面)
当我碰它的时候 , 我喜欢它, cuz 她呻吟 lil 咬
珍 saggin', 因此我能看见她的皮带 lil 咬
我认识被种植 lil 的她咬,20 岁, 你合法的
离开我的民族不 跌倒, 正直的单脚跳在那帝王的
我在她的同类一只鹰之上抓取, 俯冲下和比率
我知道你的流行, 但是你 gon 今天是出名的
我喜欢你所做的方式正确的 thurr(正确的 thurr)
当你走路的时候 , 发飕飕声你的臀部, 感到失望的你头发 (下你的 hurr 置于地面)
我喜欢那你做正确的 thurr 什么 (正确的 thurr)
变湿你的唇当你说话的时候, 那使我成为 slurr(使我成为 slurr)
我喜欢你所做的方式正确的 thurr(正确的 thurr)
当你走路的时候 , 发飕飕声你的臀部, 感到失望的你头发 (下你的 hurr 置于地面)
我喜欢那你做正确的 thurr 什么 (正确的 thurr)
变湿你的唇当你说话的时候, 那使我成为 slurr(使我成为 slurr)
她是在前面的 nack shoppin, 正直的神情在她的前面背面
配备人手她是 soo 堆积,做她知道我想要那
他使他是 soo 重击, 少女能 i 味道你的猫
给予了她的 300$ 花费, 同类买投-背面
她停留在俱乐部中, 像他们说她得到了它
在真正的生活方面,少女使我想起 pochantas
她是在事件, 像最好的何时她越过
所有的高 rollin'猫, wana 薪资为 ssss
Niggas 一半的 steppin', 用皮绳捆住的由于一个美好的武器
它是反对法律让她移动他们臀部
如果你曾经看到它肮脏,离去下降的你嘴
宽的世界,愚人 volenteer 告诉你它的远顶端
我喜欢你所做的方式正确的 thurr(正确的 thurr)
当你走路的时候 , 发飕飕声你的臀部, 感到失望的你头发 (下你的 hurr 置于地面)
我喜欢那你做正确的 thurr 什么 (正确的 thurr)
变湿你的唇当你说话的时候, 那使我成为 slurr(使我成为 slurr)
我喜欢你所做的方式正确的 thurr(正确的 thurr)
当你走路的时候 , 发飕飕声你的臀部, 感到失望的你头发 (下你的 hurr 置于地面)
我喜欢那你做正确的 thurr 什么 (正确的 thurr)
变湿你的唇当你说话的时候, 那使我成为 slurr(使我成为 slurr)
当她正在做的时候 , 我喜欢它 (发生)
Cuz 当她把它带来回来的时候 , 我喜欢它
ohhh ohhh ohhh ohhh 做你所做的
当她正在做那的时候 , 我喜欢它 (uhhh)
Cuz 当她把它带来回来的时候 , 我喜欢它
ohhh ohhh ohhh ohhh 做你所做的
Gimmie 你所为一块猪排得到的 (uh)
她在我丢它喜欢我是一个表演停止 (uh)
Twerkin 在一个 phatty 少女中使顶端停止
然后她在我身上支持它, 而且让它降低 (下降)
使它单脚跳 (boing), 像一只兔子 (兔子)
我能碰你它是阳光充足的哪里吗
或使, 困窘而且使你给我们一些钱
她应该为运动 illustriated 摆姿势
它像照片完成式位置
当她经过所有的另一个少女憎恨的时候。
但是我喜欢你所做的方式正确的 thurr(正确的 thurr)
当你走路的时候 , 发飕飕声你的臀部, 感到失望的你头发 (下你的 hurr 置于地面)
我喜欢那你做正确的 thurr 什么 (正确的 thurr)
变湿你的唇当你说话的时候, 那使我成为 slurr(使我成为 slurr)
我喜欢你所做的方式正确的 thurr(正确的 thurr)
当你走路的时候 , 发飕飕声你的臀部, 感到失望的你头发 (下你的 hurr 置于地面)
我喜欢那你做正确的 thurr 什么 (正确的 thurr)
变湿你的唇当你说话的时候, 那使我成为 slurr(使我成为 slurr)
我喜欢那
我喜欢那
我喜欢那
我喜欢那表示惊讶表示惊讶表示惊讶
我喜欢那
我喜欢那
我喜欢那
我喜欢那表示惊讶表示惊讶表示惊讶


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/12736569.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-27
下一篇 2023-05-27

发表评论

登录后才能评论

评论列表(0条)

保存