Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Beginning Android Application Development
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Android Application Development
This is the forum to discuss the Wrox book Beginning Android Application Development by Wei-Meng Lee; ISBN: 978-1-1180-1711-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Android Application Development section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 28th, 2012, 07:22 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Chapter 8 Messaging and Networking

In Chapter 8 Messaging and Networking, the example that is given to send sms under "TRY IT OUT" does not seem to work the code is giving error. even when i am running it by downloading the example code it still not working. Its to be noted that my SDK is fine i can compile and run other codes that i have written.
Any help regarding this topic will be highly appreciated.
Thanx in advance.
Reply With Quote
  #2 (permalink)  
Old February 28th, 2012, 01:49 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Wink This code will work.

Well i was not able to solve the problem of the downloaded code but i wrote this it works and does the same task.

The file is the MainActivity.java in (NameOfYourProgramActivty.Java)
Code:
 
package com.ahitagni.test2;

import android.app.Activity;
import android.os.Bundle;


import android.app.PendingIntent;
import android.content.Intent;
import android.telephony.gsm.SmsManager;
import android.view.View;
import android.widget.Button;

public class Test2Activity extends Activity {
	Button btnSendSMS;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        btnSendSMS = (Button) findViewById(R.id.btnSendSMS);
        btnSendSMS.setOnClickListener(new View.OnClickListener()
        {
        	public void onClick(View v)
        	{
        		sendSMS("5556","Hello this is a test");
        		
        	}
        });
    }
    private void sendSMS(String phoneNumber,String message)
    {
      SmsManager sms = SmsManager.getDefault();
      sms.sendTextMessage(phoneNumber,null,message,null,null);
}
}

And the difference from the code in the book is that the import
Code:
android.telephony.SmsManager;
change that line to
Code:
import android.telephony.gsm.SmsManager;
Reply With Quote
  #3 (permalink)  
Old May 7th, 2012, 12:08 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default SMS example

I have the code from the book working fine. I am not using it in an emulator I am using on a real device. I send messages to myself. I modified the example to include text entry fields for phone number and a message body. Works great until I go to 161 characters. 160 characters works fine. The application crashes with a FATAL null pointer exception.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 8 networking sinw55 BOOK: Beginning Android Application Development 0 October 23rd, 2011 03:42 AM
Chapter 8 - <Networking> program BrianMcK BOOK: Beginning Android Application Development 1 October 21st, 2011 09:54 AM
networking help nirvaan Java Basics 1 September 13th, 2007 11:28 AM
Networking with perl ZORCH Perl 1 June 14th, 2007 12:21 AM
instant messaging with System.Messaging connect2sandep General .NET 35 March 1st, 2006 01:11 PM



All times are GMT -4. The time now is 10:22 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.