在Android 4.4系统发送彩信彩信、系统、Android

2023-09-05 04:48:37 作者:梦的方向叫做闯

我试着只从我的应用程序发送彩信。我把它默认与Android开发教程(的http://android-developers.blogspot.com/2013/10/getting-your-sms-apps-ready-for-kitkat.html).

Im trying to send mms from my app only. I made it default messaging app with help of android developers tutorial (http://android-developers.blogspot.com/2013/10/getting-your-sms-apps-ready-for-kitkat.html).

我的清单:    BroadcastReceiver的侦听收到短信息:

My manifest: BroadcastReceiver that listens for incoming SMS messages:

   <receiver android:name="com.test.SmsReceiver"
        android:permission="android.permission.BROADCAST_SMS">
        <intent-filter>
            <action android:name="android.provider.Telephony.SMS_DELIVER" />
        </intent-filter>
    </receiver>

的BroadcastReceiver监听传入彩信

BroadcastReceiver that listens for incoming MMS messages

 <receiver android:name="com.test.MmsReceiver"
        android:permission="android.permission.BROADCAST_WAP_PUSH">
        <intent-filter>
            <action android:name="android.provider.Telephony.WAP_PUSH_DELIVER" />
            <data android:mimeType="application/vnd.wap.mms-message" />
        </intent-filter>
    </receiver>

服务,从手机的快速反应提供的消息

Service that delivers messages from the phone quick response

<service android:name="com.test.HeadlessSmsSendService"
        android:permission="android.permission.SEND_RESPOND_VIA_MESSAGE"
        android:exported="true" >
        <intent-filter>
            <action android:name="android.intent.action.RESPOND_VIA_MESSAGE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="sms" />
            <data android:scheme="smsto" />
            <data android:scheme="mms" />
            <data android:scheme="mmsto" />
        </intent-filter>
    </service>

NewMmsActivity 活动,允许用户发送新的短信/彩信:

NewMmsActivity Activity that allows the user to send new SMS/MMS messages:

 <activity android:name="com.test.NewMmsActivity"
        android:configChanges="keyboard|keyboardHidden|locale|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
        android:label="@string/app_name"
        android:launchMode="singleTop"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <action android:name="android.intent.action.SENDTO" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="sms" />
            <data android:scheme="smsto" />
            <data android:scheme="mms" />
            <data android:scheme="mmsto" />
        </intent-filter>
    </activity>

但是当我尝试在 NewMmsActivity 以发送MMS它不工作,而是对话框打开这样的:

But when i try in NewMmsActivity to send an mms it doesn't work and instead dialog is open like this:

code:

  Intent mmsIntent = new Intent(Intent.ACTION_SEND);
  mmsIntent.putExtra("sms_body", "text");
  mmsIntent.putExtra("address", "99999999");
  mmsIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(fileString)));
  mmsIntent.setType("image/jpeg");
  startActivity(mmsIntent);

如果我使用Intent.ACTION_SENDTO没有任何反应。启动时不会发生任何问题意图,但什么也没发生。

If i use Intent.ACTION_SENDTO nothing happens. Intent is started without no problems but nothing is happening.

我在想什么?任何想法将AP preciated!

What am i missing?? Any ideas would be appreciated!

推荐答案

我发现发送彩信简单的方法就是Android的smsmms库这里找到:的 https://github.com/klinker41/android-smsmms

Easiest way i found for sending mms is android-smsmms library found here: https://github.com/klinker41/android-smsmms

有关,我用gettings MMSC,代理和端口:

For gettings mmsc, proxy and port i used:

 final Cursor apnCursor = SqliteWrapper.query(mContext, this.mContext.getContentResolver(),
                Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current"), APN_PROJECTION, null, null, null);
        String type = null;
        if (apnCursor.moveToFirst()) {
            do {
                type = apnCursor.getString(3);
                if(type.equals("default,supl,mms") ||
                        type.equals("mms")) {
                    mmsc = apnCursor.getString(0);
                    proxy = apnCursor.getString(1);
                    port = apnCursor.getString(2);
}while (apnCursor.moveToNext());

在循环的话,我检查,如果APN具有MMS的数据,我需要否则转到下一个。

In if loop i am checking if APN has MMS data that i need otherwise go to next one.