2

Please don`t vote down if this is a silly question please share some light here

i want to created an app for saving call history

for that i followed http://karanbalkar.com/2014/02/detect-incoming-call-and-call-hangup-event-in-android/

this site but i`m not getting the event when the app is not running.Please help

i want to get the event when a incoming call is received even when the app is closed

manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.sars.broadcasttest">

    <uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <activity android:name=".Main">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <receiver android:name=".IncommingCall">
            <intent-filter>
                <action android:name="android.intent.action.PHONE_STATE" />

            </intent-filter>
        </receiver>
    </application>

</manifest>

class file

package com.sars.broadcasttest;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

/**
 * Created by athulbabu on 18/08/15.
 */
public class IncommingCall extends BroadcastReceiver {
    int i=0;
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d("IncomingCall", "Call catched test"+i++);
        Toast.makeText(context, "Calll Intent Detected. test", Toast.LENGTH_LONG).show();
    }
}
kukku
  • 489
  • 5
  • 17

1 Answers1

2

For security reasons you have to run app at least once after install to get the BroadcastReceiver working.

Read this section: Launch controls on stopped applications http://developer.android.com/about/versions/android-3.1.html

skrzatswat
  • 59
  • 5
  • yes i had run the app and force closed from settings then it wont work or after a reboot it won`t work – kukku Aug 18 '15 at 13:38
  • After force close, app is in StoppedState and before first run. You can't do anything about that, this is new Google politics after Android 3.1. – skrzatswat Aug 18 '15 at 13:48
  • what should i do to run my app after a call received ? – kukku Aug 19 '15 at 11:31