Miss call alert in Android.....

Put your problem here if it does not fit any of the other categories.

Miss call alert in Android.....

Postby rakesh_mehta » Wed Dec 10, 2008 1:08 pm

Hi All,

My Requirement is look like this:

when some one try to miss call me then it gives me sound alert for particular duration until i picked it up..

So it is possible or not?

I have searched a lot but could not find solution..... :)

Thanks in Advance.... :)
Rakesh
User avatar
rakesh_mehta
Experienced Developer
Experienced Developer
 
Posts: 73
Joined: Tue Oct 14, 2008 6:46 am
Location: Ahmedabad(India)

Top

Postby haden » Thu Dec 11, 2008 10:27 am

Why dont you try listening for incoming calls using the PhoneStateListener . When the phone goes idel you could access the call log content provider to access you missed calls and then you could have your notification until the missed calls are cleared..
haden
Experienced Developer
Experienced Developer
 
Posts: 74
Joined: Thu Sep 11, 2008 11:51 am

Postby rakesh_mehta » Thu Dec 11, 2008 10:38 am

Ok Thanks for the reply

Hear is my code so that you have idea:


package com.android.call;


import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
import com.android.call.tele;
import android.app.Notification;

public class IncomingCall extends Activity
{
boolean flag=false;
tele t=new tele(this);
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
System.out.println("*****1");
setContentView(R.layout.main);
System.out.println("*****2");
//final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
TelephonyManager telephony = (TelephonyManager)this.getSystemService(this.TELEPHONY_SERVICE);
System.out.println("*****3");
telephony.listen(t,PhoneStateListener.LISTEN_CALL_STATE);
System.out.println("*****4");
System.out.println("*******************"+flag);

}
private void callmethod() {


}


}
class tele extends PhoneStateListener
{
IncomingCall in;
public tele(IncomingCall incomingCall) {

System.out.println("*****5");
// TODO Auto-generated constructor stub
this.in=incomingCall;
}

public void onCallStateChanged(int state, String incomingNumber)
{
//Log.d("****DEBUG", TelephonyManager.CALL_STATE_OFFHOOK + " weeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee are def in here: " + state);
System.out.println("*****6");
switch(state)
{
case TelephonyManager.CALL_STATE_IDLE:
Log.d("***DEBUG", "***** phone is idle");
in.flag=false;
break;

case TelephonyManager.CALL_STATE_RINGING:
Log.d("****DEBUG", "***** phone is ringing");
in.flag=true;
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
Log.d("****DEBUG", "***** phone is Disconnected");
in.flag=false;
break;

default:
Log.d("***** DEBUG", "***** The state is " + state);
in.flag=false;
break;


}


}


}
Last edited by rakesh_mehta on Thu Dec 11, 2008 12:46 pm, edited 1 time in total.
Rakesh
User avatar
rakesh_mehta
Experienced Developer
Experienced Developer
 
Posts: 73
Joined: Tue Oct 14, 2008 6:46 am
Location: Ahmedabad(India)

Postby haden » Thu Dec 11, 2008 11:19 am

Off Hook is when the phone is busy . you need to listen for the the phone ringing and then when it goes idle without going off hook in between. This identifies it as a missed call..
haden
Experienced Developer
Experienced Developer
 
Posts: 74
Joined: Thu Sep 11, 2008 11:51 am

Postby rakesh_mehta » Thu Dec 11, 2008 11:39 am

Ok Thanks for the Quick Reply..

Let me try than i will tell u.. :)
Rakesh
User avatar
rakesh_mehta
Experienced Developer
Experienced Developer
 
Posts: 73
Joined: Tue Oct 14, 2008 6:46 am
Location: Ahmedabad(India)

Postby rakesh_mehta » Thu Dec 11, 2008 11:55 am

Hi Haden,

After i got the miss call :) using flag where can i put the action of using that flag??

For e.g.

If i want to play the sound than i have to call new activity and when i got flag=true than and than i can call the next activity... so in which class and which method i have to right this condition for last value of flag...


Thanks in Advance..
Rakesh
User avatar
rakesh_mehta
Experienced Developer
Experienced Developer
 
Posts: 73
Joined: Tue Oct 14, 2008 6:46 am
Location: Ahmedabad(India)

Top

Postby haden » Thu Dec 11, 2008 12:12 pm

You could try something like this. It's partially working but it should help you get started.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. class tele extends PhoneStateListener {
  2.  
  3.        
  4.  
  5.         final static String TAG = "STATELISTENER";
  6.  
  7.         boolean ringing = false;
  8.  
  9.         boolean offhook = false;
  10.  
  11.         public tele() {
  12.  
  13.  
  14.  
  15.        
  16.  
  17.                
  18.  
  19.         }
  20.  
  21.  
  22.  
  23.         public void onCallStateChanged(int state, String incomingNumber) {
  24.  
  25.                
  26.  
  27.                
  28.  
  29.                
  30.  
  31.                 switch (state) {
  32.  
  33.                 case TelephonyManager.CALL_STATE_IDLE:
  34.  
  35.                         Log.d(TAG,"IDLE");             
  36.  
  37.                         Log.d(TAG,"ringing "+ringing+" offhook "+offhook);
  38.  
  39.                         if(ringing&&(!offhook))
  40.  
  41.                         {
  42.  
  43.                                 Log.d(TAG, "You've got a missed call");
  44.  
  45.                                  ringing = false;
  46.  
  47.                                  offhook = false;
  48.  
  49.                        
  50.  
  51.                         }
  52.  
  53.                         break;
  54.  
  55.  
  56.  
  57.                 case TelephonyManager.CALL_STATE_RINGING:
  58.  
  59.                         Log.d(TAG, "RINGING");
  60.  
  61.                         ringing = true;
  62.  
  63.                         offhook = false;
  64.  
  65.                        
  66.  
  67.                         break;
  68.  
  69.                 case TelephonyManager.CALL_STATE_OFFHOOK:
  70.  
  71.                         Log.d(TAG, "OFFHOOK");
  72.  
  73.                         offhook = true;
  74.  
  75.                         ringing = false;
  76.  
  77.                         break;
  78.  
  79.  
  80.  
  81.                 default:
  82.  
  83.                                                
  84.  
  85.                         break;
  86.  
  87.                 }
  88.  
  89.                
  90.  
  91.                
  92.  
  93.  
  94.  
  95.         }
  96.  
  97.  
  98.  
  99. }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
haden
Experienced Developer
Experienced Developer
 
Posts: 74
Joined: Thu Sep 11, 2008 11:51 am

Postby rakesh_mehta » Wed Dec 17, 2008 11:28 am

Thanks haden..

Its working now.......... :)

Thanks again :)
Rakesh
User avatar
rakesh_mehta
Experienced Developer
Experienced Developer
 
Posts: 73
Joined: Tue Oct 14, 2008 6:46 am
Location: Ahmedabad(India)

Your program

Postby jankware » Tue Dec 23, 2008 9:00 am

I'm new to Java and android from a programming stand point, I've programmed with visual basic.net for a couple of years now but I'm trying to make a program that does exactly what yours does, I'm examining what you did here but I still don't understand the language enough. I was wondering if I could get a copy of your working
program? Its really driving me nuts when I miss a phone call and it don't notify me in anyway other than a
flashing LED!

Thanks,
Keith
Keith
jankware
Freshman
Freshman
 
Posts: 3
Joined: Tue Dec 23, 2008 8:44 am
Location: San Jose

I need this to work

Postby jankware » Sat Jan 03, 2009 12:24 am

Can you at least help me out with the IncomingCall class?

Thanks
Keith
jankware
Freshman
Freshman
 
Posts: 3
Joined: Tue Dec 23, 2008 8:44 am
Location: San Jose

Postby rakesh_mehta » Mon Jan 05, 2009 12:04 pm

Hii jankware..

Actually right now i am working on miss call alert application... There are some problem's there.. after that i will send u a source code......
Rakesh
User avatar
rakesh_mehta
Experienced Developer
Experienced Developer
 
Posts: 73
Joined: Tue Oct 14, 2008 6:46 am
Location: Ahmedabad(India)

Re: Miss call alert in Android.....

Postby anupsoft007 » Thu Apr 04, 2013 4:04 am

Hi Rakesh,

Can you send me the source code to detect a missed call?

Thanks,
Anup
anupsoft007
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Apr 03, 2013 8:03 pm

Re: Miss call alert in Android.....

Postby NdotIndia » Thu Apr 04, 2013 8:31 am

I really appreciate you.... Very good concept.
NdotIndia
Experienced Developer
Experienced Developer
 
Posts: 51
Joined: Tue Apr 03, 2012 11:20 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 39 guests