当前位置:编程学习 > wap >>

我一调用sendTextMessage 程序就退出了 是怎么回事呢

SmsManager smessage=SmsManager.getDefault();
smessage.sendTextMessage(telnum, null, mestext, null, null);  
一执行到上一句,程序退出了,无论在手机还是模拟器中都是这样 androi,移动开发,发送短信 --------------------编程问答-------------------- <uses-permission android:name="android.permission.SEND_SMS"/>  权限 --------------------编程问答-------------------- <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.message"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />
android:permission="android.permisson.SEND_SMS"
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.message.MainActivity"
           
            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>

</manifest>


我加上这句话了,是不是位置加的不对? --------------------编程问答--------------------
引用 2 楼 missing01 的回复:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.message"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />
android:permission="android.permisson.SEND_SMS"
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.message.MainActivity"
           
            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>

</manifest>


我加上这句话了,是不是位置加的不对?
错了,
<uses-permission android:name="android.permisson.SEND_SMS"/>
放在跟application同级节点下 --------------------编程问答-------------------- 大哥你这个怎么加进去的!把我那个copy到application节点外面 --------------------编程问答-------------------- 把你标红的那行换成<uses-permission android:name="android.permission.SEND_SMS"/>就搞定了 --------------------编程问答--------------------
引用 楼主 missing01 的回复:
SmsManager smessage=SmsManager.getDefault();
smessage.sendTextMessage(telnum, null, mestext, null, null);  
一执行到上一句,程序退出了,无论在手机还是模拟器中都是这样

搞定没 --------------------编程问答-------------------- 我觉得应该这个毛病,但是上班没有这个环境,没办法试试呀 --------------------编程问答-------------------- 静待佳音。顺带说一下发短信还有别的办法的,我给你贴一个你参谋参谋

Intent sendIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + phone));
if (this.getPackageManager().resolveActivity(sendIntent, 0) == null) {
Toast.makeText(mContext, "系统不支持此功能", 0).show();
return;
}
startActivity(sendIntent); --------------------编程问答-------------------- 按照你说的,还是不太行 ,还是直接退出了 ,不晓得哪儿 的问题 --------------------编程问答--------------------
引用 8 楼 pengguohua1988 的回复:
静待佳音。顺带说一下发短信还有别的办法的,我给你贴一个你参谋参谋

Intent sendIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + phone));
if (this.getPackageManager().resolveActivity(sendIntent, 0) == null) {
Toast.makeText(mContext, "系统不支持此功能", 0).show();
return;
}
startActivity(sendIntent);


这个是对用intent方法吗? --------------------编程问答--------------------
引用 6 楼 pengguohua1988 的回复:
Quote: 引用 楼主 missing01 的回复:

SmsManager smessage=SmsManager.getDefault();
smessage.sendTextMessage(telnum, null, mestext, null, null);  
一执行到上一句,程序退出了,无论在手机还是模拟器中都是这样

搞定没[/quo
搞定了  原来是一个单词拼写错了 --------------------编程问答--------------------
引用 11 楼 missing01 的回复:
Quote: 引用 6 楼 pengguohua1988 的回复:

Quote: 引用 楼主 missing01 的回复:

SmsManager smessage=SmsManager.getDefault();
smessage.sendTextMessage(telnum, null, mestext, null, null);  
一执行到上一句,程序退出了,无论在手机还是模拟器中都是这样

搞定没[/quo
搞定了  原来是一个单词拼写错了


什么单词拼错了? --------------------编程问答-------------------- permisson
补充:移动开发 ,  Android
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,