黑马程序员技术交流社区
标题:
求解
[打印本页]
作者:
熊曼
时间:
2015-3-20 21:43
标题:
求解
public class SMSBroadcastReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent)
{
// TODO Auto-generated method stub
System.out.println("锟斤拷锟斤拷锟铰的o拷锟斤拷锟脚碉拷锟斤拷锟剿★拷锟斤拷");
//取锟斤拷锟斤拷锟斤拷锟脚碉拷锟斤拷锟�
Object[] objs = (Object[]) intent.getExtras().get("pdus");//锟斤拷锟斤拷锟斤拷锟介。
for(Object obj : objs){
SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) obj);
String body = smsMessage.getMessageBody();
String sender = smsMessage.getOriginatingAddress();
System.out.println("body:"+body);
System.out.println("sender:"+sender);
if("Warnning".equals(body))
{
MediaPlayer myplayer=new MediaPlayer();
try
{
myplayer.setDataSource("");
}
catch (IllegalArgumentException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (SecurityException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IllegalStateException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
try
{
myplayer.prepare();
}
catch (IllegalStateException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
myplayer.start();
abortBroadcast();
}
}
}
}
为什么手机收到Warnning后,并设置了setDataSource还是不会有声音播放啊
作者:
shamoman
时间:
2015-3-21 22:32
这应该放到别的版块去问撒,傻
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2