Emulator control not working

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Emulator control not working

Postby yashas » Mon Aug 02, 2010 12:10 pm

Hello,

I have coded an application to receive sms in android 2.1 and show it in the form of a toast. But i'm not able to simulate the incoming sms. I tried doing it with emulator control in DDMS view. No luck.. After clicking send with incoming number and message nothing happens in the emulator.

I tried by starting two emulators and trying to simulate sending of sms but no luck here either.. :cry:

please help me... here is my code :

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3.      package="com.wissen.sms"
  4.      android:versionCode="1"
  5.      android:versionName="1.0">
  6.     <application android:icon="@drawable/icon" android:label="@string/app_name">
  7.         <activity android:name=".MainAcivity"
  8.                  android:label="@string/app_name">
  9.             <intent-filter>
  10.                 <action android:name="android.intent.action.MAIN" />
  11.                 <category android:name="android.intent.category.LAUNCHER" />
  12.             </intent-filter>
  13.         </activity>
  14.  
  15.     <receiver android:name=".receiver.SMSReceiver" android:enabled="true">
  16.     <intent-filter>
  17.     <action android:name="android.provider.Telephony.SMS_RECEIVED" />
  18.     </intent-filter>
  19.     </receiver>
  20. </application>
  21.     <uses-sdk android:minSdkVersion="7" />
  22.  
  23. <uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
  24. </manifest>
  25.  
Parsed in 0.004 seconds, using GeSHi 1.0.8.4


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. import android.content.BroadcastReceiver;
  2. import android.content.Context;
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.telephony.SmsMessage;
  6. import android.widget.Toast;
  7.  
  8. public class SMSReceiver extends BroadcastReceiver {
  9.  
  10.         private static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
  11.         /**
  12.          * @see android.content.BroadcastReceiver#onReceive(android.content.Context,
  13.          *      android.content.Intent)
  14.          */
  15.         @Override
  16.         public void onReceive(Context context, Intent intent) {
  17.                 if (intent.getAction().equals(SMS_RECEIVED)) {
  18.                         Bundle bundle = intent.getExtras();
  19.  
  20.                         Object messages[] = (Object[]) bundle.get("pdus");
  21.                         SmsMessage smsMessage[] = new SmsMessage[messages.length];
  22.                         for (int n = 0; n < messages.length; n++) {
  23.                                 smsMessage[n] = SmsMessage.createFromPdu((byte[]) messages[n]);
  24.                         }
  25.  
  26.                         // show first message
  27.                         Toast toast = Toast.makeText(context, "Received SMS: "
  28.                                         + smsMessage[0].getMessageBody(), Toast.LENGTH_LONG);
  29.                         toast.show();
  30.                 }
  31.         }
  32. }
  33.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. import android.app.Activity;
  2. import android.os.Bundle;
  3.  
  4. public class MainAcivity extends Activity {
  5.     /** Called when the activity is first created. */
  6.     @Override
  7.     public void onCreate(Bundle savedInstanceState) {
  8.         super.onCreate(savedInstanceState);
  9.         setContentView(R.layout.main);
  10.     }
  11. }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
yashas
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Aug 02, 2010 9:07 am

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 9 guests