我尝试使用PduParser from AOSP.来解析彩信,我在我的清单中使用WAP_PUSH_RECEIVED
来接收彩信,然后我将它们传输到我收看的BroadcastReceiver。已定义。但是,在创建新的PduParser
obejct时,我收到以下错误。
12-21 20:14:43.063 25939-25939/com.ollien.smspusher E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.ollien.smspusher, PID: 25939
java.lang.NoSuchMethodError: No direct method <init>([B)V in class Lcom/google/android/mms/pdu/PduParser; or its super classes (declaration of 'com.google.android.mms.pdu.PduParser' appears in /system/framework/telephony-common.jar)
at com.ollien.smspusher.MMSReceiver.onReceive(MMSReceiver.java:28)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3187)
at android.app.ActivityThread.-wrap17(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1672)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
导致错误的代码片段如下
public class MMSReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
byte[] data = extras.getByteArray("data");
PduParser parser = new PduParser(data);
}
}
这是我AndroidManifest.xml的相关部分
<receiver
android:name=".MMSReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED" />
<data android:mimeType="application/vnd.wap.mms-message" />
</intent-filter>
</receiver>
不确定我哪里出错了。如果有人能指出我正确的方向,我真的很感激。