B4A Library ToggleLibrary

Discussion in 'Additional libraries, classes and official updates' started by XverhelstX, Nov 3, 2011.

  1. XverhelstX

    XverhelstX Well-Known Member Licensed User

    Hey everyone,

    This is an improvement of my TurnGPS Library.
    ToggleLibrary is great to use in homescreen widgets or just normal apps.
    With ToggleLibrary, you can currently do the following:

    - Bluetooth: Toggle, Enable, Disable, Check.
    - Airplane Mode: Toggle, Enable, Disable, Check.
    - WiFi: Toggle, Enable, Disable, Check.
    - GPS: Toggle, Enable, Disable, Check.
    - DataConnection** (GPRS,...): Toggle, Enable, Disable, Check.
    - RingerMode: Toggle, Enable, Disable. (Vibrate, Silent or Normal)
    - Change Brightness
    - Change Mediavolume.
    - Reboot, GotoSleep, UserActivity, isScreenOn

    There might still be a few bugs. Please let me know.

    * With check, I mean that you can check if it's enabled(true) or disabled (false)
    ** Depends on device

    Attached are the library files.
    No sample is added because it is all self-explanatory.

    Code:
    Dim TGL As Toggle
    TGL.Initialize()
    TGL.TurnBluetoothOn


    Tomas
     

    Attached Files:

    noeleon, toby, Melghost and 7 others like this.
  2. bluedude

    bluedude Well-Known Member Licensed User

    Would you be interested to do some paid/sponsored work? Je spreekt ook Nederlands volgens mij?
     
  3. XverhelstX

    XverhelstX Well-Known Member Licensed User

    Jup, inderdaad. ;)

    Contacteer me via pm. Het meeste doe ik wel gratis, tenzij ik veel werk en tijd ergens instop. Hangt af van wat je nodig hebt.

    Tomas
     
  4. Ronny

    Ronny Member Licensed User

    No Reeboot

    Thanks for this lib. :)

    I can't get the "Reboot" to work. The program crash with the included error. I suspect this wil only work on rooted devices?
    Code:
    'Activity module
    Sub Process_Globals
       
    'These global variables will be declared once when the application starts.
       'These variables can be accessed from all modules.
       Dim t As Toggle
    End Sub

    Sub Globals
       
    'These global variables will be redeclared each time the activity is created.
       'These variables can only be accessed from this module.
       Dim RebootButton As Button
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
       
    Activity.LoadLayout("main_layout")
       t.Initialize
    End Sub

    Sub Activity_Resume

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

    End Sub

    Sub RebootButton_Click
       t.Reboot
    End Sub

    java.lang.ClassCastException: android.media.AudioManager
    at com.rootsoft.togglelibrary.ToggleLibrary.Reboot(ToggleLibrary.java:484)
    at no.edev.reboot.main._rebootbutton_click(main.java:309)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:89)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:49)
    at android.view.View.performClick(View.java:2408)
    at android.view.View$PerformClick.run(View.java:8816)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4627)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    at dalvik.system.NativeStart.main(Native Method)
     
  5. glouie

    glouie Member Licensed User

    Hi Tomas,

    I tried using your library for Bluetooth, Airplane mode, and GPS - all of which work wonderfully.

    Thank you!
     
  6. glouie

    glouie Member Licensed User

    Reboot

    I just tested the reboot function and also get the same error that Ronny mentioned.
     
  7. NeoTechni

    NeoTechni Well-Known Member Licensed User

    I'm not sure if you did it like this, but I have your wifi toggle library and was wondering if you could make it raise an event when wifi (and the other hardware) finishes turning on, so you dont have to keep polling it.

    And all hardware would go through a single event.

    ie: _HardwareOnline(HardwareType as Int)
    HardwareType = 0 for wifi, 1 for Bluetooth, etc.
     
    Last edited: Nov 17, 2011
  8. manios

    manios Active Member Licensed User

    I tested the Bluetooth functions, works well.:)
     
  9. XverhelstX

    XverhelstX Well-Known Member Licensed User

    Ok, I will take a look at it.

    Tomas
     
  10. alibaba

    alibaba Member Licensed User

    Toggle GPS Problem with 2.3

    Toggle GPS work perfect with Android 2.2 but with Android 2.3 i have on 3 Galaxy Tabs the Problem that i can't activate the GPS if the the User has it turned Off in the pull down menu, this works on 2.2 but not with 2.3 dit anyone have a Solution for this ?
     
  11. KikeCentolo

    KikeCentolo Member Licensed User

    Do not work on ICS

    Toggle GPS work perfect with Android Gingerbread but with Android ICS i can't activate the GPS dit anyone have a Solution for this ?
    Thanks:)
     
  12. rfresh

    rfresh Well-Known Member Licensed User

    I too cannot get the .Reboot to work...I'm getting errors too...Droid2...
     
  13. rfresh

    rfresh Well-Known Member Licensed User

    On the Droid2 the .TurnOnWiFi works and the .TurnGPSOn works too...my OS shows as 2.3.x
     
  14. Bardill

    Bardill Member Licensed User

    The TurnAirPlaineModeOff not work on HTC Sensation or HTC ONE on ICS and older 2.3.x

    It Works on Samsung S2

    Is this a bug from HTC?
     
  15. rfresh

    rfresh Well-Known Member Licensed User

    Just so I'm clear, the DataConnection boolean is my celluar connection to the internet on my phone?

    I have a Droid3 with a cellular connection to the internet and I have turned off WiFi and TGL.DataConnection is false. I was expecting it to be true?

    Update: Hmmm...now the DataConnection is True (which I was expecting it to be) but my FTP won't connect to my website to download a file. If I turn on the Droid3 WiFi, it will connect and download the file. Any thoughts?
     
    Last edited: May 4, 2012
  16. marcomilazzo

    marcomilazzo Member Licensed User

    shutdown phone

    hi
    is it possible to have a shutdown implemented?

    thank's
    marco
     
  17. GaNdAlF89

    GaNdAlF89 Active Member Licensed User

    when I try this:
    Code:
    Dim t As Toggle
    t.Initialize()
    t.Reboot
    I have this exception:
    How can I resolve?
     
  18. GaNdAlF89

    GaNdAlF89 Active Member Licensed User

    No solutions??
     
  19. Erel

    Erel Administrator Staff Member Licensed User

    Which line raises this error? Please post the full error message from the logs.
     
  20. GaNdAlF89

    GaNdAlF89 Active Member Licensed User

    Sub ButtonV_Click
    Dim tgl As Toggle
    tgl.Initialize
    tgl.Reboot 'error in this line
    End Sub

     
    Last edited: Sep 3, 2012
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