WiFi Tetherinf

Discussion in 'Android Questions' started by FabioG, Mar 6, 2013.

  1. FabioG

    FabioG Active Member Licensed User

    Hi,

    I need your help

    with this code can not open Tethering Settings
    Code:
    Dim Intent1 As Intent

            Intent1.Initialize(Intent1.ACTION_MAIN,
    "")
            Intent1.SetComponent(
    "com.android.settings/com.android.settings.TetherSettings")
            
    StartActivity(Intent1)
    but I need to activate the WiFi Tethering automatically without user action.

    how can I fix this?

    thank you very much
     
  2. NJDude

    NJDude Expert Licensed User

    That code should work if the device supports Tethering.
     
  3. FabioG

    FabioG Active Member Licensed User

    of course,

    I need a code to enable WiFi tethering without user action.

    Who can help me?

    thanks
     
  4. FabioG

    FabioG Active Member Licensed User

    it is possible to ?

    with this code, but how can I use it with basic4android?


    Code:
    private void setWifiTetheringEnabled(boolean enable) {
        
    WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);

        Method[] methods = 
    wifiManager.getClass().getDeclaredMethods();
        
    for (Method method : methods) {
            
    if (method.getName().equals("setWifiApEnabled")) {
                
    try {
                    method.invoke(
    wifiManagernull, enable);
                
    } catch (Exception ex) {
                }
                break;
            }
        }
    }
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Here:
    Code:
    Sub SetWifiApEnabled(Enabled As Boolean)
       
    Dim r As Reflector
       r.Target = r.GetContext
       r.Target = r.RunMethod2(
    "getSystemService""wifi""java.lang.String")
       r.RunMethod4(
    "setWifiApEnabled"Array As Object(Null, Enabled), _
          
    Array As String("android.net.wifi.WifiConfiguration""java.lang.boolean"))
    End Sub
    You should also add this line to the manifest editor:
    Code:
    AddPermission(android.permission.CHANGE_WIFI_STATE)
    It will not work on all devices.
     
  6. FabioG

    FabioG Active Member Licensed User

    does not work on my Galaxy Nexus

    There are other solutions, or other methods?

    thanks
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    This is a hidden API. It will probably only work on older devices. I'm not familiar with any other way.
     
  8. FabioG

    FabioG Active Member Licensed User

    Ok,

    thanks so much for the answer
     
  9. FabioG

    FabioG Active Member Licensed User

    Erel,

    with this code I open the general settings for Tethering

    Code:
    Dim Intent1 As Intent

        Intent1.Initialize(Intent1.ACTION_MAIN,
    "")
        Intent1.SetComponent(
    "com.android.settings/com.android.settings.TetherSettings")
        
    StartActivity(Intent1)
    how can I open the configuration Dialog of WiFi HotSpot?
     
  10. NJDude

    NJDude Expert Licensed User

    Like I said on my previous post, the device MUST support it, for example, if I ran that code on my EVO I can see and get the WiFi Tether Settings and activate them, if I ran the same code on a Nexus 7 tab, I open the screen but the screen is BLANK, on a Galaxy tab shows the settings and able to change the settings, on other devices you might even see a blank screen like I mentioned or just disabled buttons.

    Like Erel also mentioned, it's a hidden API which is usually managed by the telcom provider.
     
  11. FabioG

    FabioG Active Member Licensed User

    I know that already, in fact I have already implemented all the controls.

    I need to figure out how to open the CONFIGURATION Dialog of WiFi HotSpot.
     
  12. FabioG

    FabioG Active Member Licensed User



    Erel,

    how can I use Reflector to change the SSID and Key?

    I read this but I do not understand: (
    WifiConfiguration | Android Developers
    thanks
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    It will be difficult to do it with Reflector. You will need to write a library for that (check ABWifi first).
     
  14. FabioG

    FabioG Active Member Licensed User

    ABWifi if I'm not mistaken the opportunity to read the information and do not write.

    thanks anyway
     
  15. Gustavo Holtermann

    Gustavo Holtermann Member Licensed User

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice