HOW DETECT SEND EVENT?

General topics about the Android-Platform itself.
Coding issues please to the subforum right below.

HOW DETECT SEND EVENT?

Postby albertochap » Wed Feb 25, 2009 12:46 am

Hello,

Is it possible to detect send event? The idea is adding a text at the end of sms when the user push on send button.

Thanks!!!
albertochap
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Feb 25, 2009 12:39 am

Top

Re: HOW DETECT SEND EVENT?

Postby geosk » Thu Feb 26, 2009 2:25 pm

I'm working with same problem.
I hope that if I start two emulators android.intent.action.SEND will help me, but nothing.
I've send message from one two another but... nothing happened.

Any ideas?
geosk
Freshman
Freshman
 
Posts: 3
Joined: Thu Feb 26, 2009 2:20 pm

Re: HOW DETECT SEND EVENT?

Postby geosk » Tue Mar 03, 2009 8:48 pm

albertochap wrote:Hello,

Is it possible to detect send event? The idea is adding a text at the end of sms when the user push on send button.

Thanks!!!


Register SMS observer

ContentResolver contentResolver = getContentResolver();
Handler handler = new Handler();
m_SMSObserver = new SMSObserver(handler);
m_SMSObserver.setReactor(this);
contentResolver.registerContentObserver(Uri.parse("content://sms"), true, m_SMSObserver);

And detect last message protocol

Uri uriSMSURI = Uri.parse("content://sms");
Cursor cur = this.getContentResolver().query(uriSMSURI, null, null, null, null);
cur.moveToNext();
String protocol = cur.getString(cur.getColumnIndex("protocol"));
if(protocol == null)
onSMSSend();
else
onSMSReceive();
geosk
Freshman
Freshman
 
Posts: 3
Joined: Thu Feb 26, 2009 2:20 pm

Postby Draffodx » Fri Jan 15, 2010 12:18 pm

Sorry to bump an old post but....


theres no such class as SMSObserver?
Draffodx
Master Developer
Master Developer
 
Posts: 205
Joined: Wed Nov 12, 2008 2:31 pm

Postby geosk » Sat Jan 16, 2010 7:18 am

SMSObserver is self developed class.

public class SMSObserver extends ContentObserver{

private EventHandling m_reactor;

@Override
public void onChange(boolean selfChange) {
// TODO Auto-generated method stub
super.onChange(selfChange);

m_reactor.onSMSHandled();
}

@Override
public boolean deliverSelfNotifications() {
// TODO Auto-generated method stub
return false;
}

public SMSObserver(Handler handler) {
super(handler);
// TODO Auto-generated constructor stub
}

public void setReactor(EventHandling reactor){
m_reactor = reactor;
}

}
geosk
Freshman
Freshman
 
Posts: 3
Joined: Thu Feb 26, 2009 2:20 pm

Postby Draffodx » Mon Jan 18, 2010 11:24 am

Thanks, I realised that after posting :oops:

I have done the same thing as that but I keep getting asked for the READ_SMS permission even though it is already declared properly in the manifest.

It happens when trying to register the contentobserver to the sms Uri

Would you have any ideas why that would be happening?
Draffodx
Master Developer
Master Developer
 
Posts: 205
Joined: Wed Nov 12, 2008 2:31 pm

Top

Postby Draffodx » Mon Jan 18, 2010 12:59 pm

I got it sorted!

I can now detect sms send and recieve events

But I cant block an sms from sending, is this possible?
Draffodx
Master Developer
Master Developer
 
Posts: 205
Joined: Wed Nov 12, 2008 2:31 pm

Top

Return to General

Who is online

Users browsing this forum: Google Feedfetcher and 3 guests