Can I launch an Android app from the built-in Phone Call Log app?

I would like to know if it is possible to run my application whenever a new entry is recorded in the phone call log (i.e. outgoing, incoming or missed call).

I wrote an application to manage call log entries according to user preferences, listening to the publication of android.intent.action.PHONE_STATE events . My application is working fine while its process is running. However, if a user stopped my application using the killer application, the log entries could not be controlled since my application was not running. I need a way to make sure my application is running in the background if it is not already running when android.intent.action.PHONE_STATE happens .

Or can I run my application as a service that always runs?

Thanks in advance. Bala

+3
source share
2 answers

You can run the application as a Service:

http://developer.android.com/reference/android/app/Service.html

:

public class MyService extends Service
{
    @Override
    public IBinder onBind(Intent intent)
    {
        return null;
    }

    @Override
    public void onCreate()
    {
        super.onCreate();
        Log.i("Service", "Service is starting");
    }

    @Override
    public void onDestroy()
    {
        super.onDestroy();
        Log.i("Service", "Service stopped");
    }
}

AndroidManifest.xml

<application ....>
    <service android:name=".App.MySyncService" />
</application>
+2

, , , .

, . , "" > "".

, android.intent.action.PHONE_STATE .

BroadcastReceiver IntentService . , AlarmManager ( ), . Intent, , . , , (IntentService , ), , , .

, ?

, , .

0

Source: https://habr.com/ru/post/1733744/


All Articles