5
0
mirror of https://github.com/cwinfo/envayasms.git synced 2024-11-09 02:10:26 +00:00
envayasms/src/org/envaya/sms/MmsObserver.java

47 lines
1.2 KiB
Java
Raw Normal View History

2011-09-22 23:16:46 +00:00
package org.envaya.sms;
2011-09-18 01:38:16 +00:00
import android.content.Intent;
import android.database.ContentObserver;
import android.os.Handler;
import java.util.List;
final class MmsObserver extends ContentObserver {
private App app;
public MmsObserver(App app) {
super(new Handler());
this.app = app;
}
public void register()
{
app.getContentResolver().registerContentObserver(
MmsUtils.OBSERVER_URI, true, this);
MmsUtils mmsUtils = app.getMmsUtils();
List<IncomingMms> messages = mmsUtils.getMessagesInInbox();
for (IncomingMms mms : messages)
{
mmsUtils.markOldMms(mms);
}
}
public void unregister()
{
app.getContentResolver().unregisterContentObserver(this);
}
2011-09-18 01:38:16 +00:00
@Override
public void onChange(final boolean selfChange) {
super.onChange(selfChange);
if (!selfChange)
{
// check MMS inbox in an IntentService since it may be slow
// and we only want to do one check at a time
app.startService(new Intent(app, CheckMmsInboxService.class));
}
}
}