当手机连接到特定的wifi网络时如何拒绝接听电话。

时间:2017-10-29 11:33:00

标签: android

我的代码如下。请帮助我。它无法正常工作。无线网络运行正在运行,但在调用方法callCut();时它无法运行

       public class WifiReciever extends BroadcastReceiver {
        `` String state;

         @Override
            public void onReceive(Context context, Intent intent) {
         state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
      NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
            if (info != null && info.isConnected()) {

                WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
                WifiInfo wifiInfo = wifiManager.getConnectionInfo();
                bssid1 = wifiInfo.getIpAddress();
               Toast.makeText(context, ""+bssid1, Toast.LENGTH_SHORT).show();

            }
if (bssid1==67217600)
         {
            Toast.makeText(context, "connected to"+bssid1, Toast.LENGTH_SHORT).show();

             callCut();


         }
        else
      {
          Toast.makeText(context, "different netwrk "+bssid1, Toast.LENGTH_SHORT).show();
      }


    }
  private void callCut()
    {
        if (state.equals(TelephonyManager.EXTRA_STATE_RINGING))
        {
          //call reject
        }
        else
        {
            //normal
        }
        }
        }

0 个答案:

没有答案