How to disable SMS notification by code

Quickly share your Android Code Snippets here...

How to disable SMS notification by code

Postby yhqalise » Sun Oct 18, 2009 4:03 pm

HI all,

I want to now how to disable SMS notification by code. Who can help?
yhqalise
Freshman
Freshman
 
Posts: 2
Joined: Tue Oct 13, 2009 9:03 am

Top

Re: How to disable SMS notification by code

Postby jaboho » Mon Oct 26, 2009 4:50 pm

I am also interested in this solution. Do you know the solution yet? Please let me know too.
yhqalise wrote:HI all,

I want to now how to disable SMS notification by code. Who can help?
www.codemobiles.com
First Thai International Mobiles Dev. Community
jaboho
Freshman
Freshman
 
Posts: 3
Joined: Sat May 30, 2009 5:31 pm

Re: How to disable SMS notification by code

Postby dooom » Wed Mar 17, 2010 5:52 pm

jaboho wrote:I am also interested in this solution. Do you know the solution yet? Please let me know too.
yhqalise wrote:HI all,

I want to now how to disable SMS notification by code. Who can help?


This is not exactly what you want. It just discard the SMS when the phone receive it.

Any way :

First declare an intent filter in your manifest :
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.                 <receiver android:name="SMSReceiver">
  2.                         <intent-filter>
  3.                                 <action android:name="android.provider.Telephony.SMS_RECEIVED" />
  4.                                 <category android:name="android.intent.category.DEFAULT" />
  5.                         </intent-filter>
  6.                 </receiver>
  7.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


Then code it :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class SMSReceiver extends BroadcastReceiver {
  3.  
  4.         public static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
  5.  
  6.         private static ZServerClientApi zServerClientApi;
  7.  
  8.         @Override
  9.         public void onReceive(Context context, Intent intent) {
  10.                 if (SMS_RECEIVED.equals(intent.getAction()) {
  11.                         this.abortBroadcast();
  12.                 }
  13.         }
  14. }
  15.  
  16.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
dooom
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Mar 17, 2010 5:39 pm

Re: How to disable SMS notification by code

Postby apurva.giri » Tue Aug 31, 2010 9:28 am

this code doesn't work in real devices (tested on SPICA 2.1) but on emulator, its working fine...
apurva.giri
Freshman
Freshman
 
Posts: 9
Joined: Thu Aug 19, 2010 12:08 pm

Top

Return to Code Snippets for Android

Who is online

Users browsing this forum: No registered users and 2 guests