Question

I need to listen all incoming and outgoing sms and store it in a text file. For this I am using broadcast listener to listen all incoming messages. This works fine. But for outgoing sms, how to register content observer without activity? I don't want any activity in my application. Now the broadcast receiver listens even after reboot, will content observer too listen even after reboot? How to merge these two functions?

Here is part of my manifest.xml

<receiver class="map" android:name=".map" android:enabled="true">

            <intent-filter>

                <action android:value="android.provider.Telephony.SMS_RECEIVED"                   android:name="android.provider.Telephony.SMS_RECEIVED" />

            </intent-filter>

        </receiver>

Here, the class that extends broadcast receiver

public class map extends BroadcastReceiver {
    /** Called when the activity is first created. */
    private static final String ACTION = "android.provider.Telephony.SMS_RECEIVED";
    public void onReceive(Context context, Intent intent) 
    { 
                  // Here I store the sms in text file

    }

Any help is appreciated. Thanks.

Was it helpful?

Solution

You'll need a http://developer.android.com/reference/android/app/Service.html . Create one of those, set it to run on boot and register your content observer from in there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top