检测在Android彩信 [英] Detecting MMS messages on Android

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

问题描述

我正在寻找通过互联网这个话题,但没有找到任何令人满意的答案... 我试图侦测彩信(进入至少在开始)。而且我已经决定要经过检测改变内容的方式。 我下载的Andr​​oid codeS和确信,我使用的是正确的内容提供商:内容://彩信(在android.provider.Telephony.Mms类),我使用所有需要的权限 (来自彩信的应用程序) 我想出了一个示例应用程序,检测收到MMS彩信,怎么过不检测它们。这里是应用程序:

I was searching through the internet for this topic and couldn't find any satisfying answer... I'm trying to detect MMS messages (incoming at least for start). And I've decided to go through the way of detecting changes in the contents. I've downloaded Android codes and made sure that I'm using correct content provider: "content://mms" (in android.provider.Telephony.Mms class) and I'm using all needed permissions (from Mms application) I've come up with a sample application that detects incoming MMS messages, how ever it does not detect them. here is the application:

package com.kolomiyets.MMStesting;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Bundle;
import android.widget.TextView;

public class MMStesting extends Activity {

public static final String MMSMON_RECEIVED_MMS = "MMStesting.intent.action.MMSMON_RECEIVED_MMS";

Uri mmsInURI = Uri.parse("content://mms");

ContentObserver mmsObserver = new ContentObserver(null) {
    @Override
    public void onChange(boolean selfChange) {

        Thread mmsNotify = new Thread(){
            @Override
            public void run() {
                Intent mIntent = new Intent(MMSMON_RECEIVED_SMS);
                sendBroadcast(mIntent);
                super.run();
            }
        };
        mmsNotify.start();
        super.onChange(selfChange);
    }
};

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    BroadcastReceiver mmsMonitorBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            TextView log = (TextView)findViewById(R.id.mms_log);
            log.append("\n MMS Received;");
        }
    };

    IntentFilter mIntentFilter = new IntentFilter();
    mIntentFilter.addAction(MMSMON_RECEIVED_MMS);

    registerReceiver(mmsMonitorBroadcastReceiver, mIntentFilter);

    getApplicationContext().getContentResolver().registerContentObserver(mmsInURI, true, mmsObserver);
    getApplicationContext().getContentResolver().notifyChange(mmsInURI, mmsObserver);


}

@Override
protected void onDestroy() {
    getApplicationContext().getContentResolver().unregisterContentObserver(mmsObserver);
    super.onDestroy();
}
}

和清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.kolomiyets.MMStesting"
  android:versionCode="1"
  android:versionName="1.0">
<uses-sdk android:minSdkVersion="4" />

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_MMS"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.WRITE_SMS"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INSTALL_DRM"/>


<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".MMStesting"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

</application>

到目前为止,我试过的内容:// MMS短信和应用程序开始检测什么设备接收彩信不休之后。没有迹象显示有关在状态栏中新的MMS(因为它应该是),但在收到的消息O_O

So far I tried "content://mms-sms" and application starts detecting something endlessly after device receives MMS message. There is no indication about new MMS in the status bar(as it should be), however the message appears in the incoming messages o_O...

此外,我试图把内容://短信和一切工作,因为它应该(检测进来的和发出的短信,甚至彩信O_O的)

Also I tried putting "content://sms" and everything works as it supposed to (detection of incomming and outgoing SMSs and even MMSs o_O)

我误解的东西吗? 是否有办法来纠正我的应用程序,所以它会检测到变化的内容://彩信? 如果它不能在此应用程序的工作,比我将不能够使用我的数据库请求的内容吗? 如果我会检测与变化的内容://短信我怎么能分辨短信和彩信的? (我想获得什么是MMS以及)。 或者可能是最好的想法只是把所有的类Android的来源,并试图修改它们就是我想要的? ...但我would'n喜欢这样做)))

Do I misunderstand something? Is there a way to correct my app so it would detect changes in "content://mms"? If it does not work in this app, than I won't be able to use this content in my database requests? If I'll detect changes with "content://sms" how can I distinguish between SMS and MMS? (I'd like to get what is in MMS as well). Or may be the best idea is just taking all those classes from android sources and trying to modify them the way I want? ...But I would'n like to do it)))

下面是一个

<一个href="http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/1.6_r2/android/provider/Telephony.java?av=f">grep$c$c.com:包含MMS calass 电话类(也是该网站方便​​浏览Android源$ C ​​$ C)

grepcode.com: Telephony class that contains MMS calass (also this site is convenient for browsing android source code)

此信息有所描述,如何从MMS消息是在数据库中的信息。不过,我仍然想不通的方式为检测迁入和传出的彩信。

This information somewhat describes, how to retrieve information from MMS messages that are in the database. However, I still can't figure out the way to detect ingoing and outgoing MMS messages.

它看起来像我,我要监控:以检测彩信内容//短信(因为内容://短信反作用于传入的彩信和内容://彩信没有) ,并且比工作的内容://彩信,在光标和ContentResolver的

It looks like to me that I have to to monitor "content://sms" in order to detect MMSs (since "content://sms" reacts on incoming MMSs and "content://mms" does not), and than work with "content://mms" over Cursor and ContentResolver.

但我不知道这是一个正确的道路......此外,我不明白究竟是什么部件(或PduPart)重新presents ......我会得到一个完整的画面通过彩信或检索零件这将是图片的一部分?而有任何区别的内容:// //彩信部分和内容:// MMS /零件/?

But I'm not sure this is a right way... Also I don't understand what actually Part (or PduPart) represents... will i get a complete picture by retrieving Part from MMS or it will be a part of the picture? And is there any difference between "content://mms//part" and "content://mms/part/"?

下面也是一个有趣的时刻与WAP PUSH信息。据我了解,这些重新present某种带有超链接一些特殊的短信,他们也被用来从移动服务提供商转移配置到客户的手机上。这个类:

Here is also an interesting moment with WAP Push Messages. As far as I've understood these represent some kind of some special SMS messages with hyper links, and they are also used to transfer configurations from mobile provider to client's phone. This class:

<一个href="http://$c$c.google.com/p/android-notifier/source/browse/trunk/AndroidNotifier/src/org/damazio/notifier/service/MmsReceiver.java?r=141">$c$c.google.com: MmsReceiver.java 应该检测与WAP推送按摩帮助彩信。

code.google.com: MmsReceiver.java is supposed to detect MMS messages with help of WAP Push Massages.

我真的没有意义了吧。怎么样?

I really can't make sense out of it. How?

推荐答案

在检测进来的MMS消息是很容易,只要把广播接收器监测WAP_PUSH_RECIEVED事件,如...

Detecting an incomming MMS message is easy, just put in broadcast receiver monitoring WAP_PUSH_RECIEVED events, as in...

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

决策意识出了什么,你得到的是一个困难得多。我设法去code一切,我从WAP_PUSH_RECEIVED意图想通过彩信应用克隆PDU解析code。

Making sense out of what you get is a lot harder. I managed to decode everything I wanted from the WAP_PUSH_RECEIVED intent by cloning the PDU parsing code from the Mms app.

检索从零件文件中的实际内容是什么,我还在工作,这是我发现了这个话题摆在首位。

Retrieving the actual contents from the part files is what I am still working on, which is how I found this topic in the first place.

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

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