Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 28th, 2012, 07:22 AM
Registered User
 
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.
 
Old February 28th, 2012, 01:49 PM
Registered User
 
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;
 
Old May 7th, 2012, 12:08 PM
Registered User
 
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.





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.