-1

hi im usuing simulator for testing application but when i run application, it still show gprs available any idea why?? in simulator there is no gprs then why its show gprs available?? what is ConnectivityManager.TYPE_MOBILE mean? is mean only 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) {

   }

 });
Ajay Soman
  • 1,631
  • 4
  • 19
  • 37

1 Answers1

0

The ConnectionManager doesn't check the type of with the provided type (TYPE_MOBILE). It only reports that a data connection exists regardless of the underlying protocol.

NetworkInfo.getSubTypeName() will have the subtype of the network.

Also there's this existing answer to a similar question.

Community
  • 1
  • 1
Dan S
  • 9,139
  • 3
  • 37
  • 48
  • then how to check gprs wifi any other type network is available or not?? – Lovely Buddy Aug 03 '12 at 22:10
  • `ConnectionManager` types are related to hardware interface. Review `TYPE_` members from the [ConnectionManager](http://developer.android.com/reference/android/net/ConnectivityManager.html) reference. – Dan S Aug 03 '12 at 22:28
  • ok u just tell me any idea how do i check gprs wifi availability in phone programically??? – Lovely Buddy Aug 03 '12 at 22:29