Call Drop problem..

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

Call Drop problem..

Postby techkanika » Thu Aug 19, 2010 9:15 am

I want to disconnect incoming call programmatically but when I am trying to use

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. import com.android.internal.telephony.phone
  2.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


it is not resolved..
When i googled regarding this, it shows we can't import non public APIs. One solution i found is :
Use framework.jar in classpath and then create object of this Phone interface. But problem is I didn't found this jar file and secondly it is device specific.

Can we use RIL (radio interface layer) to implement this feature ??

Please reply...

Thanks
Kanika
Thanks
Kanika Rakheja
User avatar
techkanika
Experienced Developer
Experienced Developer
 
Posts: 83
Joined: Fri May 28, 2010 7:49 am

Top

Re: Call Drop problem..

Postby vicvondoom » Sat Aug 21, 2010 10:29 pm

Try this..

in 'com.android.internal.telephony' place this interface:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.android.internal.telephony; //this is a must!
  2.  
  3.  
  4.  
  5. /* Copyright (C) 2007 The Android Open Source Project
  6.  
  7. *
  8.  
  9. * Licensed under the Apache License, Version 2.0 (the "License");
  10.  
  11. * you may not use this file except in compliance with the License.
  12.  
  13. * You may obtain a copy of the License at
  14.  
  15. *
  16.  
  17. *      http://www.apache.org/licenses/LICENSE-2.0
  18.  
  19. *
  20.  
  21. * Unless required by applicable law or agreed to in writing, software
  22.  
  23. * distributed under the License is distributed on an "AS IS" BASIS,
  24.  
  25. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  26.  
  27. * See the License for the specific language governing permissions and
  28.  
  29. * limitations under the License.
  30.  
  31. */
  32.  
  33.  
  34.  
  35. //package com.android.internal.telephony;
  36.  
  37.  
  38.  
  39. /**
  40.  
  41. * Interface used to interact with the phone.  Mostly this is used by the
  42.  
  43. * TelephonyManager class.  A few places are still using this directly.
  44.  
  45. * Please clean them up if possible and use TelephonyManager insteadl.
  46.  
  47. *
  48.  
  49. * {@hide}
  50.  
  51. */
  52.  
  53. public interface ITelephony {
  54.  
  55.  
  56.  
  57.    /**
  58.  
  59.     * End call or go to the Home screen
  60.  
  61.     *
  62.  
  63.     * @return whether it hung up
  64.  
  65.     */
  66.  
  67.    boolean endCall();
  68.  
  69.  
  70.  
  71.    /**
  72.  
  73.     * Answer the currently-ringing call.
  74.  
  75.     *
  76.  
  77.     * If there's already a current active call, that call will be
  78.  
  79.     * automatically put on hold.  If both lines are currently in use, the
  80.  
  81.     * current active call will be ended.
  82.  
  83.     *
  84.  
  85.     * TODO: provide a flag to let the caller specify what policy to use
  86.  
  87.     * if both lines are in use.  (The current behavior is hardwired to
  88.  
  89.     * "answer incoming, end ongoing", which is how the CALL button
  90.  
  91.     * is specced to behave.)
  92.  
  93.     *
  94.  
  95.     * TODO: this should be a oneway call (especially since it's called
  96.  
  97.     * directly from the key queue thread).
  98.  
  99.     */
  100.  
  101.    void answerRingingCall();
  102.  
  103.  
  104.  
  105.    /**
  106.  
  107.     * Silence the ringer if an incoming call is currently ringing.
  108.  
  109.     * (If vibrating, stop the vibrator also.)
  110.  
  111.     *
  112.  
  113.     * It's safe to call this if the ringer has already been silenced, or
  114.  
  115.     * even if there's no incoming call.  (If so, this method will do nothing.)
  116.  
  117.     *
  118.  
  119.     * TODO: this should be a oneway call too (see above).
  120.  
  121.     *       (Actually *all* the methods here that return void can
  122.  
  123.     *       probably be oneway.)
  124.  
  125.     */
  126.  
  127.    void silenceRinger();
  128.  
  129.  
  130.  
  131. }
  132.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


then in your main activity add this code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. import android.app.Activity;
  3. import android.content.Context;
  4. import android.media.AudioManager;
  5. import android.os.Bundle;
  6.  
  7. import java.lang.reflect.InvocationTargetException;
  8. import java.lang.reflect.Method;
  9. import com.android.internal.telephony.ITelephony;  //yeah, get the interface!
  10. import android.telephony.*;
  11.  
  12.         private TelephonyManager m_telephonyManager;
  13.         private ITelephony m_telephonyService;
  14.         private PhoneStateListener m_phoneStateListener;
  15.         private AudioManager m_audioManager;
  16.        
  17.     @Override
  18.     public void onCreate(Bundle savedInstanceState) {
  19.         super.onCreate(savedInstanceState);
  20.         setContentView(R.layout.main);
  21.        
  22.         m_telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
  23.  
  24.  
  25.         Class c = null;
  26.                 try {
  27.                         c = Class.forName(m_telephonyManager.getClass().getName());
  28.                 } catch (ClassNotFoundException e) {
  29.                         // TODO Auto-generated catch block
  30.                         e.printStackTrace();
  31.                 }
  32.         Method m = null;
  33.                 try {
  34.                         m = c.getDeclaredMethod("getITelephony");
  35.                 } catch (SecurityException e) {
  36.                         // TODO Auto-generated catch block
  37.                         e.printStackTrace();
  38.                 } catch (NoSuchMethodException e) {
  39.                         // TODO Auto-generated catch block
  40.                         e.printStackTrace();
  41.                 }
  42.         m.setAccessible(true);
  43.         try {
  44.                         m_telephonyService = (ITelephony)m.invoke(m_telephonyManager);
  45.                 } catch (IllegalArgumentException e) {
  46.                         // TODO Auto-generated catch block
  47.                         e.printStackTrace();
  48.                 } catch (IllegalAccessException e) {
  49.                         // TODO Auto-generated catch block
  50.                         e.printStackTrace();
  51.                 } catch (InvocationTargetException e) {
  52.                         // TODO Auto-generated catch block
  53.                         e.printStackTrace();
  54.                 }
  55.  
  56.         //You can also replace above 4 lines of statements to
  57.         //m_telephonyService = ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELE
  58.  
  59.         m_audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
  60.        
  61.         m_telephonyManager.listen(new MyPhoneStateListener(), PhoneStateListener.LISTEN_CALL_STATE);
  62.     }
  63.    
  64.     class MyPhoneStateListener extends PhoneStateListener
  65.     {
  66.         public void onCallStateChanged(int state, String incomingNumber)
  67.         {
  68.             m_audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
  69.  
  70.             switch (state)
  71.             {
  72.                 case TelephonyManager.CALL_STATE_IDLE:
  73.                    m_audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
  74.                    break;
  75.                 case TelephonyManager.CALL_STATE_OFFHOOK:
  76.                    //CALL_STATE_OFFHOOK;
  77.                    break;
  78.                 case TelephonyManager.CALL_STATE_RINGING:
  79.                    if (true) // if incomingNumber need to be blocked
  80.                    {
  81.                        m_telephonyService.answerRingingCall();
  82.                    }
  83.                    else
  84.                    {
  85.                        m_audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
  86.                    }
  87.                    break;
  88.                 default:
  89.                    break;
  90.              }
  91.           }
  92.         }
  93.  
Parsed in 0.046 seconds, using GeSHi 1.0.8.4


Hope that this help you, bye!

Davide.
User avatar
vicvondoom
Freshman
Freshman
 
Posts: 3
Joined: Sat Aug 21, 2010 10:12 pm

Re: Call Drop problem..

Postby techkanika » Thu Aug 26, 2010 2:29 pm

Thanks vicvondoom,

your code solved my problem. you saved me :)


Thanks
Kanika
Thanks
Kanika Rakheja
User avatar
techkanika
Experienced Developer
Experienced Developer
 
Posts: 83
Joined: Fri May 28, 2010 7:49 am

Re: Call Drop problem..

Postby ramsarvan » Mon Aug 30, 2010 8:20 am

Hi Davide,

I have a question. Adding an interface in the "com.android.internal.telephony", call drop works.
Where will be the implementation for that interface?

Whats the concept behind it and how it basically works?
It would be very much helpful to me as I am
customizing the com.telephony.internal.

Waiting for your reply

Thank you,
Ram
ramsarvan
Junior Developer
Junior Developer
 
Posts: 11
Joined: Sun Dec 07, 2008 6:38 pm

Re: Call Drop problem..

Postby Dolly » Tue Mar 01, 2011 6:45 am

Hello all can please help me to tell that
HOW TO IMPORT ITELEPHONY.AIDL IN COM.ANDROID.INTERNAL.

I have created a sample project and have Itelephony.aidl .Now i want to import this in com.android.internal
Please help its urgent
Dolly
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Mar 01, 2011 6:41 am

Re: Call Drop problem..

Postby cbhatt02 » Tue Jan 29, 2013 5:36 am

hey vicvondoom,
i m getting error in ur above given code
can u help me please?
cbhatt02
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Jan 28, 2013 2:28 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 22 guests