My Android app freezes when I send the function "SendTextMessage". My code looks like this:
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 Tex开发者_运维百科t...");
SmsManager sm = SmsManager.getDefault();
sm.sendTextMessage("#########(censoreD)", null, "lol", null, null);
tv1.setText("Message Sent.");
}
How can I fix this? Nothing is wrong with my 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>
thanks.
I'm going to guess and say you dont have the right permission.
android.permission.SEND_SMS
All permissions available: http://developer.android.com/reference/android/Manifest.permission.html
精彩评论