【发布时间】:2014-09-23 14:19:45
【问题描述】:
我正在尝试仅从我的应用程序发送彩信。在 android 开发者教程 (http://android-developers.blogspot.com/2013/10/getting-your-sms-apps-ready-for-kitkat.html) 的帮助下,我将其设为默认消息传递应用程序。
我的清单:
BroadcastReceiver 监听传入的 SMS 消息:
<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 监听传入的 MMS 消息
<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 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 允许用户发送新 SMS/MMS 消息的活动:
<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 中发送彩信时,它不起作用,而是像这样打开对话框:
代码:
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 什么都不会发生。 Intent 启动时没有问题,但什么也没有发生。
我错过了什么?
【问题讨论】:
-
您能否详细说明“不起作用”。你有错误吗?图片不显示?
-
@RyPope:什么也没发生。 Intent 启动,但没有发送任何内容。
-
好的,试试我的答案