Display Message

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Display Message

Postby baskar » Tue Apr 08, 2008 12:00 pm

Hi plusminus,

how to display sms message to other class textview...
i try this NullPointerException Throws..
any idea...

Regards,
Baskar
baskar
Developer
Developer
 
Posts: 46
Joined: Wed Dec 26, 2007 6:03 am
Location: India

Top

Postby kiran » Tue Apr 08, 2008 12:43 pm

Hi,
Had similar issue while using code from SMSReceiver tutorial. The exception occurred only when running from eclipse. Used putExtra() to pass the message to the SMSActivity class. Use try catch to handle the exception when bundle.getExtra("message") fails. This I think is because no SMS data is passed while running the app from eclipse. when the app actually reacts to an SMS, data is passed and the message is displayed in the TextView. Hope this helps you.
Regards,
Kiran.
:) smile it is the key that fits the lock of everybody's heart
User avatar
kiran
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Thu Nov 22, 2007 11:36 am
Location: India

Postby baskar » Tue Apr 08, 2008 12:51 pm

Thanks for u r replay..
i try this...


Regards,
Baskar
baskar
Developer
Developer
 
Posts: 46
Joined: Wed Dec 26, 2007 6:03 am
Location: India

Postby baskar » Tue Apr 08, 2008 1:00 pm

Hi Kiran,

How to get message in SMSActivity :?:

i.putExtra("Message", "MyString"); used to SMSReceiver


Regards,
Baskar
baskar
Developer
Developer
 
Posts: 46
Joined: Wed Dec 26, 2007 6:03 am
Location: India

Postby kiran » Tue Apr 08, 2008 1:18 pm

Hi,
I used the following code in SMSActivity to get the message in onCreate() method.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. String text = new String();
  3.  
  4. Bundle extras = getIntent().getExtras();
  5.  
  6. try{
  7.  
  8.         text = extras.getString("message");
  9.  
  10.     } catch (Exception e){
  11.  
  12.          text = "no message";
  13.  
  14.     }
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
Regards,
Kiran.
:) smile it is the key that fits the lock of everybody's heart
User avatar
kiran
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Thu Nov 22, 2007 11:36 am
Location: India

Postby baskar » Tue Apr 08, 2008 1:36 pm

Hi Kiran,

it is work very fine..

whenever i send sms automatically call my application.it is run...

but my application is open it is not work..

any idea..

Regards,
Baskar
baskar
Developer
Developer
 
Posts: 46
Joined: Wed Dec 26, 2007 6:03 am
Location: India

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 8 guests