当我使用SendTextMessage函数时,Android SmsManager冻结

问题描述

| 发送功能\“ SendTextMessage \”时,我的Android应用程序冻结。我的代码如下所示:
    public void doIt(View target) {
    ProgressBar pb1 = (ProgressBar)findViewById(R.id.progressBar1);
    TextView tv1 = (TextView)findViewById(R.id.textView3);
    pb1.setVisibility(View.VISIBLE);
    tv1.setVisibility(View.VISIBLE);
    tv1.setText(\"Sending Text...\");
    SmsManager sm = SmsManager.getDefault();
    sm.sendTextMessage(\"#########(censoreD)\",null,\"lol\",null);
    tv1.setText(\"Message Sent.\");
}
我怎样才能解决这个问题?我的main.xml没有任何问题:
<Button android:onClick=\"doIt\" android:layout_width=\"200sp\" android:id=\"@+id/button1\" android:layout_height=\"wrap_content\" android:text=\"Send Messages\" android:layout_x=\"62dip\" android:layout_y=\"189dip\"></Button>
谢谢。     

解决方法

        我会猜测并说您没有正确的权限。
android.permission.SEND_SMS
所有可用权限:http://developer.android.com/reference/android/Manifest.permission.html     

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...