problems with SMSReceiver

Put your problem here if it does not fit any of the other categories.

problems with SMSReceiver

Postby dkkundudolan » Thu Mar 20, 2008 11:01 am

Hi All,

I had worked on the SMSReceiver. its running, but afterthat, its not working. please reply me soon.

i had gone through the following:

Android Manifest.xml:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3.  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5.    package="com.android.ibt.sms">
  6.  
  7.     <uses-permission android:name="android.permission.RECEIVE_SMS" />
  8.  
  9.     <application android:icon="@+drawable/icon">
  10.  
  11.         <!-- The Main Activity that gets started by the IntentReceiver listed below -->
  12.  
  13.         <activity android:name=".SMSActivity" android:label="@string/app_name">
  14.  
  15.             <intent-filter>
  16.  
  17.                 <action android:name="android.intent.action.MAIN" />
  18.  
  19.                 <category android:name="android.intent.category.LAUNCHER" />
  20.  
  21.             </intent-filter>
  22.  
  23.         </activity>
  24.  
  25.          <receiver android:name=".RepeatingAlarm" android:process=":remote" />
  26.  
  27.         <!-- This class will react on the SMS show a notification
  28.  
  29.                        and start the Main-App afterwards -->
  30.  
  31.         <receiver android:name=".SMSReceiver" android:process=":remote" >
  32.  
  33.             <intent-filter>
  34.  
  35.                 <action android:name="android.provider.Telephony.SMS_RECEIVED" />
  36.  
  37.             </intent-filter>
  38.  
  39.         </receiver>    
  40.  
  41.     </application>
  42.  
  43. </manifest>
Parsed in 0.004 seconds, using GeSHi 1.0.8.4


Java:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.android.ibt.sms;
  2.  
  3.  
  4.  
  5. import android.content.Context;
  6.  
  7. import android.content.Intent;
  8.  
  9. import android.content.IntentReceiver;
  10.  
  11. import android.os.Bundle;
  12.  
  13. import android.provider.Telephony;
  14.  
  15. import android.telephony.gsm.SmsMessage;
  16.  
  17. import android.util.Log;
  18.  
  19. import android.widget.Toast;
  20.  
  21.  
  22.  
  23. public class SMSReceiver extends IntentReceiver {
  24.  
  25.  
  26.  
  27.      private static final String LOG_TAG = "SMSReceiver";
  28.  
  29.  
  30.  
  31.      
  32.  
  33.      private static final String ACTION = "android.provider.Telephony.SMS_RECEIVED";
  34.  
  35.      
  36.  
  37.   // @Override
  38.  
  39.      public void onReceiveIntent(Context context, Intent intent) {
  40.  
  41.           if (intent.getAction().equals(ACTION)) {
  42.  
  43.                
  44.  
  45.                StringBuilder sb = new StringBuilder();
  46.  
  47.                
  48.  
  49.                
  50.  
  51.                Bundle bundle = intent.getExtras();
  52.  
  53.                if (bundle != null) {
  54.  
  55.                    
  56.  
  57.                     SmsMessage[] messages =
  58.  
  59.                          Telephony.Sms.Intents.getMessagesFromIntent(intent);
  60.  
  61.                    
  62.  
  63.                    
  64.  
  65.                     for (SmsMessage currentMessage : messages){
  66.  
  67.                          sb.append("Received compressed SMS\nFrom: ");
  68.  
  69.                        
  70.  
  71.                          sb.append(currentMessage.getDisplayOriginatingAddress());
  72.  
  73.                          sb.append("\n----Message----\n");
  74.  
  75.                        
  76.  
  77.                          sb.append(currentMessage.getDisplayMessageBody());
  78.  
  79.                     }
  80.  
  81.                }
  82.  
  83.              
  84.  
  85.                Log.i(LOG_TAG, "[SMSApp] onReceiveIntent: " + sb);
  86.  
  87.  
  88.  
  89.                
  90.  
  91.                Toast.makeText(context, sb.toString(), Toast.LENGTH_LONG).show();
  92.  
  93.  
  94.  
  95.                
  96.  
  97.                this.abortBroadcast();
  98.  
  99.                
  100.  
  101.              
  102.  
  103.                Intent i = new Intent(context, SMSActivity.class);
  104.  
  105.                i.setLaunchFlags(Intent.NEW_TASK_LAUNCH);
  106.  
  107.                context.startActivity(i);
  108.  
  109.           }
  110.  
  111.      }
  112.  
  113. }
Parsed in 0.038 seconds, using GeSHi 1.0.8.4


SMSActivity:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.android.ibt.sms;
  2.  
  3.  
  4.  
  5.  
  6.  
  7. import android.app.Activity;
  8.  
  9. import android.os.Bundle;
  10.  
  11. import android.widget.Button;
  12.  
  13. import android.view.View;
  14.  
  15.  
  16.  
  17. public class SMSActivity extends Activity {
  18.  
  19.  
  20.  
  21.    
  22.  
  23.     @Override
  24.  
  25.     public void onCreate(Bundle icicle) {
  26.  
  27.         super.onCreate(icicle);
  28.  
  29.         setContentView(R.layout.main);
  30.  
  31.        
  32.  
  33.                    
  34.  
  35.         Button btnAddItem = (Button) findViewById(R.id.submit);
  36.  
  37.         btnAddItem.setOnClickListener(btnAddItemListener);
  38.  
  39.     }
  40.  
  41.     private Button.OnClickListener btnAddItemListener =
  42.  
  43.             new Button.OnClickListener() {
  44.  
  45.  
  46.  
  47.                 public void onClick(View v) {
  48.  
  49.                  
  50.  
  51.                 }
  52.  
  53.                 };
  54.  
  55.     }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
dkkundudolan
Experienced Developer
Experienced Developer
 
Posts: 83
Joined: Mon Mar 03, 2008 12:50 pm

Top

Postby plusminus » Fri Mar 21, 2008 11:24 am

Hello,

why do you have a "[font=Lucida Console]android:process=":remote"[/font]" :?:

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby E.Jyothsna » Mon Apr 07, 2008 6:45 am

i had used "android:process=":remote"" for instant messages.

please reply me as soon as possible.

thanks,

dolan
E.Jyothsna
Junior Developer
Junior Developer
 
Posts: 22
Joined: Thu Feb 28, 2008 12:25 pm
Location: chennai

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 18 guests