监测MMS_RECEIVED像SMS_RECEIVED在Android [英] Monitoring MMS_RECEIVED like SMS_RECEIVED on android

查看:365
本文介绍了监测MMS_RECEIVED像SMS_RECEIVED在Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我设置了播放,当你收到一条消息,彩信或短信,它被设置声音的程序。我得到了它与短信工作,但MMS不会做任何事情。下面是类code在运行的BroadcastReceiver:

So I'm setting up a program that plays a sound that is set when you receive a message, mms or sms. I got it to work with SMS but MMS doesn't do anything. Here is the code for the class that runs the BroadcastReceiver:

/**
 * This class overrides the main BroadcastReceiver to play the tone
 * at the given textSoundPath.
 * @author Jesse Stewart
 *
 */
public class TextMonitor extends BroadcastReceiver {

    public static String textSoundPath;     //this is the sound set to play when
                                            //sms or mms is received.

    @Override
    public void onReceive(Context arg0, Intent arg1) {
        MediaPlayer tonePlayer = new MediaPlayer();

        try {
            tonePlayer.setDataSource(textSoundPath);
        } catch (Exception e) {
            System.out.println("Couldn't set the media player sound!!!!!");
            e.printStackTrace();
        }

        try {
            tonePlayer.prepare();
        } catch (Exception e) {
            System.out.println("Couldn't prepare the tone player!!!!!");
            e.printStackTrace();
        }

        tonePlayer.start();
    }

}

我把它架在这样的清单:

I set it up in the manifest like this:

<receiver android:name=".TextMonitor">
    <intent-filter>
        <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            <action android:name="android.provider.Telephony.MMS_RECEIVED" />
    </intent-filter>
</receiver>

当然,

和包括:

<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECEIVE_MMS" />

我也试过在这样的清单做接收器:

I also tried doing the receiver in the manifest like this:

<receiver android:name=".TextMonitor">
    <intent-filter>
        <action android:name="android.provider.Telephony.SMS_RECEIVED" />
    </intent-filter>
</receiver>

<receiver android:name=".TextMonitor">
    <intent-filter>
            <action android:name="android.provider.Telephony.MMS_RECEIVED" />
    </intent-filter>
</receiver>

我也试图把在接收器:

I also tried putting in the receiver:

<action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED" />

但是,这只是做什么工作。

But that just made nothing work.

任何帮助将是AP preciated。谢谢。在一个侧面说明太,你为什么在类名前加上一个期限,有时在清单中,但不是别人? Android这样的:名称=。TextMonitor,然后有时机器人:名字=TextMonitor

Any help would be appreciated. Thanks. On a side note too, why do you put a period before the class name sometimes in the manifest but not others? like android:name=".TextMonitor" and then sometimes android:name="TextMonitor".

推荐答案

您还需要指定数据方案。

Manifest条目应该是

Manifest entry should be

<receiver android:name=".PushReceiver">
  <intent-filter>
    <action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED" />
    <data android:mimeType="application/vnd.wap.mms-message" />
  </intent-filter>
</receiver>

这篇关于监测MMS_RECEIVED像SMS_RECEIVED在Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆