I write this code in manifest file :
<uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />
    
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".Realstate"
            android:exported="false" 
                       android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="ir.smspeik.sms.realstate" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>        <receiver android:name=".ReceiveSms" 
android:exported="false">
            <intent-filter>
                <action 
android:name="android.provider.Telephony.SMS_RECEIVED"></action>
            </intent-filter>
        </receiver>
       </application>
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission  android:name="android.permission.RECEIVE_SMS" />
 
and this code in ReceiveSms : 
*

package
*

ir.smspeik.sms;

**
*

import
*

android.content.BroadcastReceiver;
**
*

import
*

android.content.Context;
**
*

import
*

android.content.Intent;
**
*

import
*

android.os.Bundle;
**
*

import
*

android.telephony.SmsMessage;
**
*

import
*

android.widget.Toast;

**
*

public
*

*class* ReceiveSms *extends* BroadcastReceiver{

@Override

*public* *void* onReceive(Context context, Intent intent)

{

//---get the SMS message passed in---

Bundle bundle = intent.getExtras();

SmsMessage[] msgs = 

*null*;

String str = 

"";

*if* (bundle != *null*)

{

//---retrieve the SMS message received---

Object[] pdus = (Object[]) bundle.get(

"pdus");

msgs = 

*new* SmsMessage[pdus.length];

*for* (*int* i=0; i<msgs.length; i++){

msgs[i] = SmsMessage.*createFromPdu*((

*byte*[])pdus[i]);

str += 

"SMS from " + msgs[i].getOriginatingAddress();

str += 

" :";

str += msgs[i].getMessageBody().toString();

str += 

"\n";

}

//---display the new SMS message---

Toast.*makeText*(context, str, Toast.

*LENGTH_LONG*).show();

}

}

}

but when I send sms to emulator the application doesn't receive it and 
builtin messaging get sms.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to