Can't send SMS message? *Update, security issue!*

Put your problem here if it does not fit any of the other categories.

Can't send SMS message? *Update, security issue!*

Postby Paladyr » Fri Mar 26, 2010 3:10 pm

I figured out how to use DDMS and can now see that I get an error saying user (number) does not have android.permission.SEND_SMS. What the heck????



I'm debugging on my Droid. When I click the button to send the message, I get an error saying:

"The application HelloAndroid (process stever.HelloAndroid) has stopped unexpectedly. Please try again.

This happens every time. I can send text msgs manually just fine on the device. I replaced my number with 5555555555. Here is the code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. package stever.HelloAndroid;
  3.  
  4.  
  5.  
  6. import android.app.Activity;
  7.  
  8. import android.app.PendingIntent;
  9.  
  10. import android.content.Intent;
  11.  
  12. import android.os.Bundle;
  13.  
  14. import android.telephony.SmsManager;
  15.  
  16. import android.view.View;
  17.  
  18. import android.view.View.OnClickListener;
  19.  
  20. import android.widget.Button;
  21.  
  22. import android.widget.EditText;
  23.  
  24. import android.widget.TextView;
  25.  
  26.  
  27.  
  28. public class HelloAndroid extends Activity {
  29.  
  30.  
  31.  
  32.     @Override
  33.  
  34.     public void onCreate(Bundle savedInstanceState) {
  35.  
  36.         super.onCreate(savedInstanceState);
  37.  
  38.         setContentView(R.layout.main);
  39.  
  40.         EditText edtX = (EditText) findViewById(R.id.edtX);
  41.  
  42.         EditText edtY = (EditText) findViewById(R.id.edtY);
  43.  
  44.         EditText edtZ = (EditText) findViewById(R.id.edtZ);
  45.  
  46.         Button SendSMS = (Button) findViewById(R.id.btnSendSms);
  47.  
  48.         edtX.setText("X Coordinate");
  49.  
  50.         edtY.setText("Y Coordinate");
  51.  
  52.         edtZ.setText("Z Coordinate");        
  53.  
  54.        
  55.  
  56.         SendSMS.setOnClickListener( new OnClickListener()
  57.  
  58.         {
  59.  
  60.                 public void onClick(View viewParam)
  61.  
  62.                 {
  63.  
  64.                         sendSMS("5555555555", "This is a text message");
  65.  
  66.                 }
  67.  
  68.         }  
  69.  
  70.         );        
  71.  
  72.     }
  73.  
  74.    
  75.  
  76.     private void sendSMS(String phoneNumber, String Message)
  77.  
  78.     {
  79.  
  80.         SmsManager sms = SmsManager.getDefault();
  81.  
  82.         PendingIntent smsPI = PendingIntent.getActivity(this, 0, new Intent(this, HelloAndroid.class), 0);
  83.  
  84.                 sms.sendTextMessage(phoneNumber, null, Message, smsPI, null);
  85.  
  86.     }
  87.  
  88. }
  89.  
  90.  
Parsed in 0.037 seconds, using GeSHi 1.0.8.4


Thanks!
Paladyr
Freshman
Freshman
 
Posts: 5
Joined: Thu Mar 25, 2010 8:22 pm

Top

Postby Paladyr » Fri Mar 26, 2010 7:28 pm

I figured it out, had to add the permission to the manifest file. Phew this is a tough transition from developing windows apps in VB .NET!!!!
Paladyr
Freshman
Freshman
 
Posts: 5
Joined: Thu Mar 25, 2010 8:22 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google Feedfetcher and 14 guests