-1

こんにちは、アプリケーションのテストにシミュレーターを使用していますが、アプリケーションを実行すると、gprs が利用可能であることが表示されます。シミュレーターにはgprsがないのに、なぜgprsを表示できるのですか?? ConnectivityManager.TYPE_MOBILE とはどういう意味ですか? gprsだけですか??

adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  sp.setAdapter(adapter);

sp.setOnItemSelectedListener(new OnItemSelectedListener() {

  public void onItemSelected(AdapterView<?> parent, View view, int position, long 
 id) {



    if (position == 0) 

    {
        final ConnectivityManager connMgr = (ConnectivityManager) 
                getSystemService(Context.CONNECTIVITY_SERVICE);

         android.net.NetworkInfo mobile =


connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
         if( mobile.isAvailable() ){
            Toast.makeText(LoginScreen.this, " GPRS Connection Found "
 , Toast.LENGTH_LONG).show();
            }
         else if( !mobile.isAvailable() ){

                Toast.makeText(LoginScreen.this, "No GPRS 
Connection Found " , Toast.LENGTH_LONG).show();
                }

    }


    if (position == 1) 
    {
        final ConnectivityManager connMgr = (ConnectivityManager)
                getSystemService(Context.CONNECTIVITY_SERVICE);

        final android.net.NetworkInfo wifi =
        connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
        if( wifi.isAvailable() ){
            Toast.makeText(LoginScreen.this, " Wifi Found" ,   
 Toast.LENGTH_LONG).show();
            }
        else if( !wifi.isAvailable() ){
            Toast.makeText(LoginScreen.this, "No Wifi found " ,
  Toast.LENGTH_LONG).show();
            }

  }




    if (position == 3) 

    {
        final ConnectivityManager connMgr = (ConnectivityManager) 
    getSystemService(Context.CONNECTIVITY_SERVICE);

         BluetoothAdapter mBluetoothAdapter = 
    BluetoothAdapter.getDefaultAdapter();    
            if (mBluetoothAdapter.isEnabled()) {
                Toast.makeText(LoginScreen.this, " BlueTooth Found" , 
   Toast.LENGTH_LONG).show();

            }else if( !mBluetoothAdapter.isEnabled() ){
                Toast.makeText(LoginScreen.this, "No BlueTooth found " 
   , Toast.LENGTH_LONG).show();
                }

    }

   }
   public void onNothingSelected(AdapterView<?> arg0) {

   }

 });
4

1 に答える 1

0

ConnectionManager、指定された型 ( ) で の型をチェックしませんTYPE_MOBILE。基になるプロトコルに関係なく、データ接続が存在することのみを報告します。

NetworkInfo.getSubTypeName()は、ネットワークのサブタイプを持ちます。

また、同様の質問に対するこの既存の回答もあります。

于 2012-08-03T21:37:32.723 に答える