Announcement

Collapse
No announcement yet.

Help with using Android phone features

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with using Android phone features

    Hi, I'm new here and this is my first post.

    I have decided to try learning how to use Android Studio, but after reading some of the posts and topics here on the forum - I think maybe I may be in way over my head.

    I would like to be able to use some of the ZTE's features - like turning on the flash LED or using one of it's sensors, but I don't know where to find out how to do that.

    In the FTC SDK there is a very nice reference which lists all of the classes and commands for controlling the motors and servos and for using the sensors, plus there are the OP Modes for examples. I have tried looking in the "help" for Android Studio several times for something like that for the phone features, but I haven't found anything yet.

    If anyone one could point me in the right direction, I would really appreciate it. Surely, there is something somewhere that tells what all the classes and commands are and how to use them.

    Thanks,

    Allen

  • #2
    Hi

    I've been playing with various phone features and would say that there isn't one great place to find out how to do things.

    I've had most success with a few different places:

    1) Android Studious has an examples section. You can get some good ideas there. At the splash screen, select "Import Android Code Sample".

    2) Youtube code searches. The easiest examples have been those with good videos. Go to youtube.com and Search for: "Android Studio FEATURE" (where FEATURE is the thing you are looking for)

    3) General Google Searches. Remember to always include "Android Studio" in the search. This will get you the most relavent examples.

    As for the Camera LED... I did a mini example here... https://www.youtube.com/watch?v=RJ4F..._pnzE2&index=3
    The link to the code is included in the comment section.

    Phil.

    Comment


    • #3
      Android Studio is an IDE and although it may have some useful examples, it is not the best place to learn Android development. For that I would start with
      http://developer.android.com/index.html.

      You can also look in the samples directory of where you installed the Android SDK ( Android Studio - File / Project Structure / SKD Location)

      And of course there is always a book. My personal favorite is "Android programming big nerd ranch guide" . However that may not have the specific examples that you may be interested in.

      Comment


      • #4
        Thanks for all of your help, I really appreciate it.

        I had tried looking on YouTube - I think just for general "Android Studio" videos, nothing specific. There were a lot of them, but I hadn't looked at any of them yet. I had tried looking on the internet for "Android Studio Text To Speech", but the two examples that I looked at were for getting text from a textbox and then saying it once a button was clicked. I was just wanting to be able to say something or use a string variable in the OP Mode to specify the text to speak. Those examples really didn't example the commands line by line in great detail - they were more like examples of how to make that app.

        Philpot,

        I did see you video for using the flash LED and I downloaded the files. I just haven't opened them. Can I have more than one project opened in Android Studio at a time or do I need to close the FTC SDK first? I wasn't sure. Would I just import your files?
        I also watched your video on wireless ADB and downloaded those files. I haven't had a chance to try them out yet either. I also watched your ZTE setup video too and used it to set up my ZTE. Thanks for doing all of those!

        dlevy,

        I tried the link that you provided and I forget how, but I found what I was looking for - a list of all of the classes and their commands. It is really nice and does go into a lot of detail with links to related topics. Unfortunately for me, I didn't understand most of it. I really have a hard time with all of the class stuff, especially the terms and it seemed to be written for programmers by programmers to me. Not something trying to explain things to beginners. That's just my impression though.

        I'm not sure what I am going to do now, I may just stick with using the FTC SDK or just wait and try App Inventor.

        Comment


        • #5
          Originally posted by matrixguy View Post
          I'm not sure what I am going to do now, I may just stick with using the FTC SDK or just wait and try App Inventor.
          The FTC SDK does not offer an easy way to read the phone sensors or manipulate the camera - which I believe is what you were originally inquiring about. This is an advanced concept for which you'll need to explore on your own for now. I not sure what you will find in the MIT App Inventor for doing this.

          The MIT App Inventor offers a limited way to create Android Apps without having to learn the java based Android SDK. Keep in mind that the FTC SDK does not require knowledge of the java based Android SDK either. So if you are going to be creating fully fledged phone apps with screens android apis .... , then MIT App Inventor may offer you a significant short cut. However for the FTC game, you will be providing some programming logic to read external sensors , turn on motors, and send telemetry. Therefore the differences between using MIT App inventor vs the FTC SDK will be far less significant.

          I'd suggest that you pick up some basic java syntax and stick with the FTC SDK.

          Comment


          • #6
            Originally posted by dlevy View Post
            The FTC SDK does not offer an easy way to read the phone sensors or manipulate the camera - which I believe is what you were originally inquiring about. This is an advanced concept for which you'll need to explore on your own for now.
            On the bright side here I didn't see anything in the rules saying we couldn't use
            any of the phone's features except for the camera, which could only be used
            for entertainment purposes.

            So, you are largely free to explore and use 3rd party libraries for doing
            almost anything you want. Should be interesting to see what people come
            up with.

            Comment


            • #7
              I can provide example code for reading GPS and compass sensors which I wrote for another project. This code makes no use of FTC SDK.

              Also: I do believe that you are allowed to use phone camera - the "entertainment only" clause of rule RE06.c only applies, AFAIK, to "additional robot electronics". There seem to be no restrictions as to how you can use electronics of the Android phone, and Tom Eng mentioned in some of the previous posts that using phone camera would be allowed (but there would be no help from FTC for doing that). Of course, it would be best to ask for confirmation in the official forum.

              Comment


              • #8
                Originally posted by dlevy View Post
                The FTC SDK does not offer an easy way to read the phone sensors or manipulate the camera - which I believe is what you were originally inquiring about. This is an advanced concept for which you'll need to explore on your own for now. I not sure what you will find in the MIT App Inventor for doing this.
                The FTC SDK is naturally oriented to the new robot hardware, and I think it's reasonable that it doesn't try and do anything else.

                Accessing Android phone stuff is covered by various Android API's which are documented and can be used in Android Studio. https://developer.android.com/about/...droid-4.4.html

                I played around with this awhile back. On GitHub you can see an app that you can build in Android Studio that makes use of android.hardware.SensorManager to list all the sensors, as well as battery level, and Wifi networks. https://github.com/acharraggi/FTC2

                From that I modified the ftc_app to create my own opModes that display all the available ZTE Speed phone sensors (as returned by SensorManager), and display the values as telemetry on the Driver Station app. Many of them don't look that useful, or the values need to be processed further, but some look quite useful. I think the OrientOp one is nice, basically showing in degrees the pitch, roll and compass heading of the phone. https://github.com/acharraggi/my_ftc_app

                I would also say that this is fairly advanced stuff. The good news is that the Android API documentation is actually pretty good. Too bad the FTC API documentation is so poor.

                Comment


                • #9
                  Originally posted by dlevy View Post
                  The FTC SDK does not offer an easy way to read the phone sensors or manipulate the camera - which I believe is what you were originally inquiring about. This is an advanced concept for which you'll need to explore on your own for now. I not sure what you will find in the MIT App Inventor for doing this.

                  The MIT App Inventor offers a limited way to create Android Apps without having to learn the java based Android SDK. Keep in mind that the FTC SDK does not require knowledge of the java based Android SDK either. So if you are going to be creating fully fledged phone apps with screens android apis .... , then MIT App Inventor may offer you a significant short cut. However for the FTC game, you will be providing some programming logic to read external sensors , turn on motors, and send telemetry. Therefore the differences between using MIT App inventor vs the FTC SDK will be far less significant.

                  I'd suggest that you pick up some basic java syntax and stick with the FTC SDK.
                  I tried out the MIT App Inventor 2 software right after I received my ZTE and it was really easy to start using. After I watched a couple of great tutorials, I was able to create a simple app to say whatever text you typed in or say something whenever you shook the phone. I modified it to say 1 of 5 random phrases whenever you shook the phone. There are a lot of great tutorials for it and I was even able to create an app to connect to and send a Bluetooth message to an NXT. I wrote a little program for the NXT to make a sound whenever it received a message and to display it on the screen. I tried modifying it to send a message back to the phone, but I couldn't get it to work at the time. I went back and looked again and the only thing I couldn't find was any controls for the flash LED. For some reason App Inventor only has controls for taking a picture with the camera.



                  Originally posted by 2009FTC3491 View Post
                  The FTC SDK is naturally oriented to the new robot hardware, and I think it's reasonable that it doesn't try and do anything else.

                  Accessing Android phone stuff is covered by various Android API's which are documented and can be used in Android Studio. https://developer.android.com/about/...droid-4.4.html

                  I played around with this awhile back. On GitHub you can see an app that you can build in Android Studio that makes use of android.hardware.SensorManager to list all the sensors, as well as battery level, and Wifi networks. https://github.com/acharraggi/FTC2

                  From that I modified the ftc_app to create my own opModes that display all the available ZTE Speed phone sensors (as returned by SensorManager), and display the values as telemetry on the Driver Station app. Many of them don't look that useful, or the values need to be processed further, but some look quite useful. I think the OrientOp one is nice, basically showing in degrees the pitch, roll and compass heading of the phone. https://github.com/acharraggi/my_ftc_app

                  I would also say that this is fairly advanced stuff. The good news is that the Android API documentation is actually pretty good. Too bad the FTC API documentation is so poor.
                  I downloaded your file. I was going to look at the Op Modes you created for viewing the sensor data. Do you think I would be able to add one of them to an FTC Op Mode? I was hoping that maybe I could just copy the code you have for reading the Orientation sensor for example and add it in. I know you said that you replaced "FtcConfig.context" with "hardwareMap.appContext" in all of those Op Modes, but I wouldn't have to do that. All I would have to do is add "hardwareMap. appContext" plus your code to an FTC Op Mode, right?

                  This may be a dumb question, but I haven't really done too much on Android Studio yet and I was just wondering if you can have more than one project open at a time or would I need to close the FTC SDK first. Then I would just import a downloaded file like yours just like I did for the FTC SDK, right?


                  I was sorted excited about switching to the new hardware, but I have to say I really don't like the software. I know that the NXT had it limitations, but the NXT-G software was really easy to learn and even a beginner could do a lot of great stuff with it. I have a lot of really great 3rd party sensors and I could make programs that talked and displayed information on the screen. All of which I can't use or do easily with the new hardware and the Java/Android software, which doesn't seem to be very beginner friendly at all. It has a lot bigger learning curve, at least for me anyway. (sorry, just my opinion)

                  Comment


                  • #10
                    Each project you open in IntelliJ, Android Studio, CLion, or any IDE with a contribution by or of a basis in JetBrains, will automatically ask if you want to open the prject in this window, or a new window. This Window closes the current project, and the New Window opens another instance of the IDE you are using.

                    Comment

                    Working...
                    X