android mms显示错误?

时间:2014-04-25 10:31:04

标签: android mms

    Intent sendIntent = new Intent(Intent.ACTION_SEND); 
                    sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
                    //sendIntent.setType("vnd.android-dir/mms-sms");
                    sendIntent.putExtra("exit_on_sent", true);
                    sendIntent.putExtra("address", number);
                    sendIntent.putExtra("sms_body", "my body");   
                    File dir = new File("/sdcard/vm/");

                    String path=dir.getAbsolutePath()+"/abc.mp4";
                    File fl=new File(path);
                    if(fl.exists()){
                        System.out.println("file is exist");
                    }
                    Uri uri = Uri.fromFile(fl);
                    sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
                    sendIntent.setType("video/*"); 
startActivityForResult(sendIntent, 1);

我正在使用此代码在某些设备上工作,但在索尼手机和其他手机中显示错误

显示错误" activity class {com.android.mms / com.android.mms.ui.ComposeMessageActivity}你在AndroidManifest.xml中声明了这个活动吗?"

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.vinstantmessage"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="18" />

    <supports-screens
        android:largeScreens="false"
        android:normalScreens="true"
        android:smallScreens="false" />

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.microphone" />

    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.SEND_SMS" />
    <uses-permission android:name="android.permission.STORAGE" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />

    <uses-feature android:name="android.hardware.camera.front" />
    <uses-feature android:name="android.hardware.microphone" />

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

    <uses-feature android:name="android.hardware.camera" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" >
    </uses-permission>
    <uses-permission android:name="android.permission.SEND_SMS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.RECORD_VIDEO" />

    <uses-feature android:name="android.hardware.camera.autofocus" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.vinstantmessage.VM_SplashScreen"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <receiver
            android:name="com.alarm.IncommingCallReceiver"
            android:enabled="true" >
            <intent-filter>
                <action android:name="android.intent.action.PHONE_STATE" />
            </intent-filter>
        </receiver>
        <receiver android:name="com.alarm.AlarmReciever" />












        <activity android:name="com.android.mms.ui.ComposeMessageActivity" > </activity> 


        <activity
            android:name="com.vinstantmessage.VM_Home"
            android:label="@string/title_activity_vm__home"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.vinstantmessage.VM_RecordVideo"
            android:label="@string/title_activity_vm__record_video"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.vinstantmessage.VM_EditVideo"
            android:label="@string/title_activity_vm__edit_video"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.vinstantmessage.VM_Settings"
            android:label="@string/title_activity_vm__settings"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.vinstantmessage.VM_ThumbNail"
            android:label="@string/title_activity_vm__thumb_nail"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.vinstantmessage.VM_ShareVideo"
            android:label="@string/title_activity_vm__share_video"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.vinstantmessage.VM_YourMessages"
            android:label="@string/title_activity_vm__your_messages"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.vinstantmessage.VM_AssignedMessages"
            android:label="@string/title_activity_vm__your_messages"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.vinstantmessage.VM_ScheduledMessages"
            android:label="@string/title_activity_vm__your_messages"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.vinstantmessage.VM_DefaultMessage"
            android:label="@string/title_activity_vm__your_messages"
            android:screenOrientation="portrait" >
        </activity>

        <receiver
            android:name="com.alarm.SMSReceiver"
            android:enabled="true" >
            <intent-filter android:priority="1000" >
                <action android:name="android.provider.Telephony.SMS_RECEIVED" />
                <action android:name="android.provider.Telephony.SMS_SENT" />
            </intent-filter>
        </receiver>
    </application>

</manifest>

3 个答案:

答案 0 :(得分:1)

我认为您必须在AndroidManifest.xml文件中声明ComposeMessageActivity。

写下以下行

<activity android:name="com.android.mms.ui.ComposeMessageActivity" > </activity> 
{p}在<application>代码中。

答案 1 :(得分:0)

在您的AndroidManifest.xml中,您需要添加com.android.mms.ui.ComposeMessageActivity,请在<application>代码

添加此活动
<application android:icon="@drawable/icon" android:label="@string/app_name">
...
       <activity android:name="com.android.mms.ui.ComposeMessageActivity" > </activity> 
...
    </application>

答案 2 :(得分:0)

使用INTENT

写下来
intent.setPackage("com.android.mms");

而不是

intent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");