• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do I use a class I found?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, I'm merely a hobbyist, I write applications because I need to use them. For the most part I've been successful at successfully completing projects with the languages I've poked around with, but for some reason Java is really not connecting with me.

I found this code example:

http://stackoverflow.com/questions/6959930/android-need-to-record-mic-input

I get it. I understand what's happening there. I have no idea, however, how I go about using it in a project. I feel like a moron for not being able to figure out what ought to be the simplest part of this process. I've worked through tutorials, I have other applications running, but I just cannot suss out where to put this or how to access it. Perhaps it's just one of those days and tomorrow it'll be crystal clear, but right now I'm deeply frustrated and could really use just a little help on this.

Thanks!
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For that particular code you need to look at some of the clues. First - the class is labeled as private - which means you are meant to put it inside some other class, probably an Activity. Second, it extends Thread (which is a bad idea) and so you generally execute a thread by calling the Thread.start method. You do not see the start() method in the posted code because it exists in the Thread class, so you have to know how to use the Thread object, or look up the API for it. You would probably call the start() method from a button click or something - that part isn't clear, but would make sense. So if I were to use that class* I would do something like this:


* If I were to use it I would probably make it not extend Thread, but that is for another discussion...
 
Sam Kostler
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks very much!

I'll give that a shot and see if I can't get it working.

I hate to bug you, but everything I've done with programming up until this has involved functions. Would you mind explaining, or pointing me to an explanation of what a class is and how it differs from a function? Also, what exactly is an activity and why do class blocks of code *have* to be in separate ones? Lastly, am I totally missing something about Java and Javascript? When I found Android used Java I was relieved since I'm reasonably comfortable with Javascript (well, really with Apps Script, but it's based on Javascript), but for the life of me I can't figure out the similarities.

Thanks again!
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sam Kostler wrote:Lastly, am I totally missing something about Java and Javascript?


The main thing you need to know is that they are completely unrelated

Sam Kostler wrote:When I found Android used Java I was relieved since I'm reasonably comfortable with Javascript


I'm afraid that won't help. If you were reasonably comfortable with Java, you'd be better off, but there would still be quite a bit to learn.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sam Kostler wrote:Would you mind explaining, or pointing me to an explanation of what a class is and how it differs from a function?


This is probably a good place to start.
 
Sam Kostler
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, I still haven't gotten it quite working, but I think I just need to step back and go through some tutorials again so I can better understand the grammar of the language (I'm not sure if that's the right word, but it seems like it fits).

I think I expected a lot more of what I knew to translate between languages and I didn't spend enough time on the basics.

Any recommendations for tutorial series' which spend a lot of time on the structure of the language as opposed to logic, variables, and conditional statements?

Thanks again!
 
reply
    Bookmark Topic Watch Topic
  • New Topic