2010-02-25 153 views
3

我的VoiP客戶端希望在我自己的通話發生時阻止所有來電。以某種方式可以做到這一點嗎?阻止來電

回答

1

與當前SDK沒有,您可以監控來電,並給用戶提供應用程序,而不是本機應用程序

+0

用戶如何選擇應用程序來回答,通過intentchooser?感謝您的幫助。 – pgsandstrom 2010-02-26 12:49:43

+0

是的,你可以註冊聽取該意圖,並啓動你的應用程序 – 2010-02-26 13:50:11

4

是可以阻止來電接聽選項。使用此代碼

String phonestate = bundle.getString(TelephonyManager.EXTRA_STATE); 

try 
    { 
     if (TelephonyManager.EXTRA_STATE_RINGING.equalsIgnoreCase(phonestate)) 
     { 
      try 
      { 
       TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); 
       Class c = Class.forName(tm.getClass().getName()); 
       Method m = c.getDeclaredMethod("getITelephony"); 
       m.setAccessible(true); 
       telephonyService = (com.android.internal.telephony.ITelephony) m.invoke(tm); 
      } 
      catch (Exception e) 
      { 
       e.printStackTrace(); 
      } 

      if (prefStatus != null) 
      { 
       if (count == 1) 
       { 
        telephonyService.endCall(); 
        String prefLoginemail = myloginpref.getString("emailid", null); 
        System.out.println(printdata + " prefLoginemail :: "+ prefLoginemail); 

        Global.mNotificationManager = (NotificationManager) mxcontext.getSystemService(Context.NOTIFICATION_SERVICE); 
        notifyDetails = new Notification(com.CellPhoneTerror.R.drawable.icon1,"CellPhoneTerror!", System.currentTimeMillis()); 
        myIntent = PendingIntent.getActivity(mxcontext, 0, new Intent(mxcontext, clsHomePage.class), 0); 

        notifyDetails.setLatestEventInfo(mxcontext,"You Got a Call from Blocked Number.", "",myIntent); 
        notifyDetails.flags |= Notification.FLAG_AUTO_CANCEL; 
        Global.mNotificationManager.notify(Global.SIMPLE_NOTFICATION_ID,notifyDetails); 

       } 
      } 
     } 
     if (prefIncomingBlock.equals("true")) 
     { 
      if (TelephonyManager.EXTRA_STATE_IDLE.equalsIgnoreCase(phonestate)) 
      { 
       if (count == 0) 
       { 
        System.out.println("if Cellphoneterror:"+ Global.clsIncomingNum); 
        Intent block = new Intent(context, dialogbox1.class); 
        block.setFlags(intent.FLAG_ACTIVITY_NEW_TASK); 
        context.startActivity(block); 
       } 
      } 
     } 
    } 
    catch (Exception e) 
    { 
     e.printStackTrace(); 
    } 

謝謝。

+0

-1我認爲提問者想知道如何做到這一點很好。 – Elemental 2011-07-27 09:19:18

+0

對不起朋友,但我的網絡被關閉了,所以我無法在這裏舉例。無論如何感謝評論。 – anddev 2011-07-27 12:52:30

+0

你怎麼能避免延遲,有時一個或兩個環被阻塞之前? – powder366 2014-07-06 15:40:31