2010-02-25 8 views
3

mon client VoiP souhaite bloquer tous les appels entrants sur le téléphone pendant que mon propre appel est en cours. Est-il possible de le faire d'une manière ou d'une autre?Bloquer les appels entrants

Répondre

1

Pas avec le SDK pas en cours, vous pouvez surveiller les appels entrants et donner à l'utilisateur la possibilité de répondre à votre demande au lieu de l'application native

+0

Comment propose-t-on à l'utilisateur de choisir une application avec laquelle il peut répondre, par le biais d'un initiateur? Merci pour ton aide. – pgsandstrom

+0

Oui, vous pouvez vous inscrire pour écouter cette intention et commencer votre application sur cette intention –

4

Oui, vous pouvez bloquer les appels entrants. En utilisant ce code

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(); 
    } 

Merci.

+0

-1 Je pense qu'il est joli que le demandeur voulait savoir comment faire. – Elemental

+0

Désolé amis, Mais mon réseau était en panne donc je ne pouvais pas mettre d'exemple ici. Quoi qu'il en soit Merci pour le commentaire. – anddev

+0

Comment pouvez-vous éviter le retard et parfois un ou deux anneaux avant son bloqué? – powder366

Questions connexes