Missed call detection in android
Hi everyone I have got the solution now its working fine with missed call.
Here my Class code MyCallListener
extended by BroadcastReciever
private static boolean ring=false;
private static boolean callReceived=false;
private String callerPhoneNumber;
private Context saveContext;
@Override
public void onReceive(Context mContext, Intent intent)
{
saveContext=mContext;
// Get the current Phone State
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if(state==null){
return;
}
Bundle bundle = intent.getExtras();
number= bundle.getString("incoming_number");
Calendar calendar=Calendar.getInstance();
currentTimeStamp=calendar.getTimeInMillis();
// If phone state "Rininging"
if(state.equals(TelephonyManager.EXTRA_STATE_RINGING))
{
ring =true;
// Get the Caller's Phone Number
}
// If incoming call is received
if(state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK))
{
callReceived=true;
}
// If phone is Idle
if (state.equals(TelephonyManager.EXTRA_STATE_IDLE))
{
// If phone was ringing(ring=true) and not received(callReceived=false) , then it is a missed call
if(ring==true&&callReceived==false)
{
Toast.makeText(mContext, "missed call : "+number, Toast.LENGTH_LONG).show();
//workingWithFunctions();
ring=false;
}
callReceived=false;
}}
dont forgot to define receiver in manifest file
<receiver android:name="com.abc.broadcastrecivers.MyBroadcastReciver" />
in the application tag
broadcast receiver for missed call in android
There is no specific broadcast for a missed call, AFAIK.
You can watch for ACTION_PHONE_STATE_CHANGED
broadcasts, wait until the phone shifts from EXTRA_STATE_RINGING
to EXTRA_STATE_IDLE
, then try checking the CallLog
content provider to see if the call was missed. I have not tried this technique, but it may work.
handle a missed call with broadcast receiver in android
I suppose you could use PhoneStateListener to listen for call state change from CALL_STATE_RINGING
to CALL_STATE_IDLE
which indicates the phone was not picked up.
Android detect missed call
You can not store any "state" information in a broadcast receiver. If you want to do a comparison old state / new state, I think you can use a service.
android oreo get incoming call number in service
From android 9, read call log permission is required. The permissions were missing.
<uses-permission android:name="android.permission.READ_CALL_LOG" />
Related Topics
CSS Overflow and Absolute Positioning Issue on Android Browser
Save Webview Content to Android Storage and Load It
Android Linearlayout Gradient Background
Which HTML Tags Are Supported by Android Textview
How to Get Canonical Id from Gcm
Materialdatepicker Get Selected Dates
In HTML5, How to Keep an Android Device's Screen On
Android Rxjava 2 Junit Test - Getmainlooper in Android.Os.Looper Not Mocked Runtimeexception
How to Get Android Avd Name from Adb Device Name
Scaling a Phonegap App for Different Android Screen Sizes/Densities
Adding a Progress Dialog in a Webview
How to Set The Title Color for The New Toolbar
How to Create a Date and Time Picker in Android
Add Maven Repository to Build.Gradle
Textview with Background Color and Line Spacing
Resources and Layout Direction Rendered Incorrectly Only on Android 8.0 and Above