Friday, May 31, 2013

Android Application Development - New Screenshots


- Added a menu when the app starts
- Added an information page which is opened when the user touches "About"
Volumes adjustment panel is fully working, thanks to ProgrammerGuru's sample.
Having a few difficulties with the toggles panel. If I can't get it to work then I'll just forget about adding it to the app (it's fairly simple to code and Android already has toggle buttons for things everywhere anyways).
Fixed problem with code not working in other activities, I was just loading the XML only, not the Java code as well, which is done by loading the activity's class through an Intent.

Saturday, May 25, 2013

Android Application Development - Progress Update

Changes so far:
- Brightness adjuster now saves as soon as you stop sliding it
- Brightness adjuster % no longer ends with ".0" or something like ".999999998"
- Added a on/off button (still needs coding) and an options link button for Wifi, Bluetooth, Airplane Mode, and vibrate
- Reorganized XML layout code and Java code a little more (will post source code with comments once project is finished)
- Fixed problems with the layout in Landscape Mode (screen sideways)


I've been working on adding volume adjusters and toggle buttons for various services, but I find that is already being enough of a challenge and a learning experience already, so it is all I'm going to attempt to add for this stage. In the process of learning how to do volume adjusters, I've actually figured out a few more things to improve the brightness adjuster from the first stage, which improvements are always good. Since the original apps activity or "screen" is becoming quite full as it is, I've been trying to add the volume adjusters and toggles on 2 more separate activities, which I've discovered causes a problem with the functioning of the Java code (although I'm thinking it's a simple line of code that I'm missing or a small setting that isn't set just right). The code compiles and runs completely fine, and I'm able to switch between activities without any problems, but the code literally has absolutely no effect on the app at all even though I get the normal and proper errors for the code if something isn't right. The code works perfectly fine if I copy everything to the apps main activity, which makes me believe that it's a small thing such as a missing line or setting that I haven't figured out quite yet, but I imagine I'll get there.

Also, if you're a beginner and are having difficulty understanding a few things, here's a list of a few definitions that I had trouble with in the beginning of this project or when I've worked with other languages before:

onCreate - This basically means "when the app starts", this is where you put all the things you want to happen when the app starts, like getting certain values, or defining certain items.

; (semicolon) - This is what you put at the end of a line, not just every line, but only a line that's finished, so there are some times that, usually for organization purposes, you will have a line or two that don't end with a ';' because these group of lines are actually read as one line by the computer (in a certain way). I think of it like a period in a sentence, a sentence can be 3 lines on a page, but just because it reaches the end of the line on the page doesn't mean the sentence is finished, it's only finished when you see the period at the end.

= and == - Though these are both "equals" they actually mean two pretty different things. '=' is what you would use when you're setting or declaring something, and '==' is used when your searching to see if something is something specific (whatever you put after the '=='). So '=' is like saying "is" and '==' is almost like saying "if it is".

!== - means the same as '==' just the '!' makes it mean "if it isn't".

public, protected, private - This is a little harder to explain, try checking out this link.

void - goes after the modifiers in the definition above (i.e. public void). This means that the function doesn't return anything to the code that called it. It's like someone calling you saying "Dinner is ready" and you heard them, they know you heard them, but yet you don't reply, because no reply is needed.

float - a number that can only go from 0.00(...) to 1.0.

int or Integer - a number without a decimal on the end.

String - text, which can also include numbers, and therefore can sometimes be converted and used like an integer (you'll see an example of this in my source code once it's posted).

When it comes to small things like this that the books don't always talk about or fully define and you get stuck on something, you just have to remember that Google is your friend.

Monday, May 13, 2013

Android Application - Stage Two Plans

I'm still currently polishing up the first stage features, like looking for improvements I could do and adding comments, reorganizing the code, etcetera. While I'm doing this I'm also planning what I'm going to do with the app next, and so far my goals of what I want to add are:
- Volume Adjusters (seek bars)
- Wifi/GPS/Data/Bluetooth/Sync on/off toggle buttons
- A really quick splash screen to show this logo
But since those seem pretty simple, and the stages are supposed to be more challenging, I'm going to try and think of something else I can add in that would be a bigger challenge. The app currently is installed on my phone and starts and performs extremely fast and hasn't crashed or had any problems yet.

Also, if you're new to Java or Android development and you're having any problems, I've found that StackOverflow has been a great amount of help for anything having to do with Java or Android. The website is almost like a "Yahoo Answers" for programming since you can read old questions that have been asked and solved, or you can create a new question and get a bunch of helpful answers. What I like about their community is that they don't just fix the code for you, but they actually explain it and explain what was wrong with your code so you actually learn.

Saturday, May 11, 2013

Android Application Development - First Stage Complete!

The app in Android 4.2.2
The app on my phone (Android 2.2.2)

























The first stage of the app is finished, with a fully working (and fixed) brightness adjuster, SD Card options link & SD Card status, and a battery status.
The two photos above aren't quite the current layout, but they're pretty close, the only difference is the test pattern image for the brightness at the bottom is now right below the brightness adjust seek bar, and the app is able to be scrolled down (had to do this so you could see everything when in  landscape mode).
I improved the brightness seek bar by fixing a problem where when the bar was dragged to 0% the screen would turn off (which is a problem that is pretty hard to get out of since the screen is completely off) by forcing the brightness value to go to 1% whenever it was brought down to 0% so it is impossible to cause the brightness to turn right off. I was luckily able to do this by a simple 2 lines of code, where many other people were trying to do this and this. I also had it display the percentage of the brightness instead of the decimal/float of it (50% would pop up as "0.5" on the screen) and the percentage doesn't show up until the bar is moved.
My plans for the SD card eject button had to be changed when I found out that Android doesn't allow apps to change and use SD card settings and actions (such as eject SD card) because it is a security risk to the user, so instead I just had the button bring the user into the storage settings menu where the "Eject SD Card" button can be found.
The battery level part was more difficult than I expected since it isn't as simple as "call BATTERY_LEVEL to get the battery's %" but it's actually more like a 'call to a call', like "call BATTERY_MANAGER to call BATTERY_LEVEL" which is a little more difficult to deal with.
I included the test pattern image so I could fill in some of that extra space, and it also helps the user adjust their brightness to something they're comfortable with.
After a few little tweaks and improvements to the current stage, I will start posting my second stage plans and layouts here, as well as a link to all the code I used and (hopefully) a video of the app.

Monday, May 6, 2013

Android Application Development - Brightness Bar Success & My Learning Approach

Without many problems, I've surprisingly already got a working brightness seek bar! I took a bit of a preview at some of the video tutorials and Android e-books and I noticed they all basically teach the exact same thing, like how to install the SDK and create your first project (which I was already much farther ahead of before I even started gathering learning resources). So since there is so little time for the culminating, and the books and video tutorials are extremely long, I thought I would try a different learning approach that has worked for me personally with many other things very well. I'm thinking I'm going to try a bit of a 'self teaching' approach, where I look at little examples of code here and there and see how others got other things to work and kind of teach myself the patterns of the code as much as I can (I find I retain this kind of information much better than if I read or hear it), and if I happen to get stuck at a certain point I can then refer to my books and videos.

 On to the brightness bar though - thanks to anindita9's brightness adjust sample, I was able to use some of the Java code on my brightness seek bar to test it out, and once I succeeded I started to 'pick apart' the Java sample line-by-line to observe how it works and functions (like what classes it uses, what methods are used, what libraries are imported, etc.). I'm starting to see how the coder set the specific seek bar to control the backlight of the screen (BackLightControl) and just used a button to update the system setting almost like a "save" button, instead of having the brightness update and save in real-time which would most likely be a bit harder to code and could even suck up more resources in the process by having the app constantly listening for changes to the setting. What surprised me with this sample is how simply coded the "update" button was, and how it basically just took the integer created from the seek bar and overwrote the brightness integer in the device's settings.

I still might make some modifications to it and see if maybe I can improve it to work even better for what I'm trying to do. I could even have like 'quick buttons' below the brightness adjuster that just quickly set it to a certain value (i.e. dark, normal, bright) or something similar to that.

Also, if you're new to OOP (Object-oriented Programming) the image below has some basic definitions that could help you understand what you're reading if you're looking up something online, reading an error, or reading a book on this kind of thing.