监控收到的彩信,如android上收到的短信

监控收到的彩信,如android上收到的短信,android,broadcastreceiver,telephony,mms,wap,Android,Broadcastreceiver,Telephony,Mms,Wap,因此,我正在设置一个程序,当您收到信息、彩信或短信时,播放设置好的声音。我把它和短信联系在一起,但彩信什么都不做。以下是运行BroadcastReceiver的类的代码: /** * This class overrides the main BroadcastReceiver to play the tone * at the given textSoundPath. * @author Jesse Stewart * */ public class TextMonitor exte

因此,我正在设置一个程序,当您收到信息、彩信或短信时,播放设置好的声音。我把它和短信联系在一起,但彩信什么都不做。以下是运行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();
    }

}
我在清单中这样设置它:

<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>
<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>

当然包括:

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

我还试着在清单中这样做接收者:

<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>
<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>

我还试着装上听筒:

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

但这根本没用


任何帮助都将不胜感激。谢谢另一方面,为什么有时在清单中在类名前加上句点,而在其他清单中不加句点?像android:name=“.TextMonitor”,然后有时是android:name=“TextMonitor”。

您还需要指定数据方案。

清单条目应为

<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>


@dj.lnxss如果它解决了您的问题,请关闭该问题。@dj.lnxss如果这是一个完美的解决方案,那么您为什么不接受作为答案。PL标记为绿色勾号:p@VipulShah彩信或任何相关数据是否与目的一致?如果是,您如何解析它?@vipulsah可以通过编程方式注册它吗?