Looking for Java Help
#1
Posted 04 December 2009 - 05:04 PM
Previously I had thought my project would involve simplicity and not-programming stuff. I've been told by my teacher that I should probably just write a program for smartphones instead of doing my original idea (which I though was more practical and easier to do).
Ideally...
GPS positioning sampling at Time 1.
GPS positioning sampling at Time 2.
Calculate distance between Sample 1 and Sample 2 in miles.
Calculate the change in Time in hours.
[Distance/(Change in Time)] = Average V.
If Average V > 20 MPH, Phone enters "Airplane Mode"
If Average V < 20 MPH, Phone functions normally.
Would anyone care to help? I've been scrambling trying to learn Java, but I'm having trouble and the big wigs of the program associated with my class are coming to see what every student has done in the first week of Jan... ANY help would be appreciated.
If you meet me:
Have some courtesy,
Have some sympathy,
And some taste.
Use all your well-learned politesse,
Or I'll lay your soul to waste.
#3
Posted 05 December 2009 - 02:42 AM
I can definitely do Hello World... learned how to script the distance formula today so that's one part of my quest.
Also I'm thinking about going about this for Android-based phones. I'll be installing the Android Plugin for Eclipse on Tuesday.
If you meet me:
Have some courtesy,
Have some sympathy,
And some taste.
Use all your well-learned politesse,
Or I'll lay your soul to waste.
#4
Posted 26 May 2010 - 12:05 AM
So far I've written the distance/velocity formula code, the GPS location sampler code, and the timertask that I think I'm going to use to run the thing "AtFixedRate".
I have a couple of questions.
1. If my GPS sampling is placed into the run() method of the timertask, would I be able to store the coordinates for each iteration of the timertask as variables? ie GPS sample at time 1 stored as x1 y1, GPS at time 2 is x2 y2, GPS at time 3 gives new values of x1 and y1, etc.
2. If I can't do that, how can I go about augmenting the GPS sample at a given rate that lets me do the above?
3. I have to put each of the individual parts together and have the code "working" [read: it has to look like it'll work, it has to theoretically work, but it probably doesn't actually have to work perfectly]. I'm going to need help with this. Any takers?
If you meet me:
Have some courtesy,
Have some sympathy,
And some taste.
Use all your well-learned politesse,
Or I'll lay your soul to waste.
#5
Posted 26 May 2010 - 08:48 AM
But of course. That's so basic, a language that can't do that would be severely crippled.If my GPS sampling is placed into the run() method of the timertask, would I be able to store the coordinates for each iteration of the timertask as variables? ie GPS sample at time 1 stored as x1 y1, GPS at time 2 is x2 y2, GPS at time 3 gives new values of x1 and y1, etc.
You should put them in a list. There are various options:
- arrays
- arraylist
- linkedlist
I'm going to let you google the rest, since it's core knowledge you'll need to understand anyway
There's really too little information abuot your project to be able to helpI have to put each of the individual parts together and have the code "working" [read: it has to look like it'll work, it has to theoretically work, but it probably doesn't actually have to work perfectly]. I'm going to need help with this. Any takers?
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."
#6
Posted 27 May 2010 - 01:31 AM
World Domination Status: ▾2.7%
#7
Posted 07 June 2010 - 11:39 PM
I have a package with the following code:
package com.ryan.android.cellsafe; import android.app.Activity; import android.os.Bundle; import android.provider.Settings; import android.provider.Settings.System; import android.widget.TextView; import android.content.Context; import android.content.ContentResolver; import android.content.Intent; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; public class CellSafe extends Activity { private TextView tv; private LocationManager lm; private LocationListener ll; double mySpeed, maxSpeed, limitSpeed; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); tv = new TextView(this); setContentView(tv); maxSpeed = mySpeed = 0; limitSpeed = 7.8232; lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); ll = new SpeedoActionListener(); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll); } private class SpeedoActionListener implements LocationListener { @Override public void onLocationChanged(Location location) { if(location!=null){ if(location.hasSpeed()){ mySpeed = location.getSpeed(); if(mySpeed>maxSpeed) maxSpeed = mySpeed; tv.setText("\nCurrent speed: " + mySpeed*2.2369 + " mph, Max speed: " + maxSpeed*2.2369 + " mph"); if(mySpeed>=limitSpeed){ //***AREA IN QUESTION*** } } } } @Override public void onProviderDisabled(String provider) { //TODO Auto-generated method stub } @Override public void onProviderEnabled(String provider) { //TODO Auto-generated method stub } @Override public void onStatusChanged(String provider, int status, Bundle extras) { //TODO Auto-generated method stub } } }
For the area in question in the above code, I have another bit of code:
package com.ryan.android.airplanechange; import android.provider.Settings; import android.app.Activity; import android.content.Context; public class AirplaneChange extends Activity { public void method() { Context context = getApplicationContext(); boolean isEnabled = Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) == 1; Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0 : 1); } }
As you can tell, they are from different packages. When the particular if statement from the first bit of code is valid, that is, the value of mySpeed is greater than or equal to the value of limitSpeed, I need the second bit of code to do its thing.
How do I make that happen?
If you meet me:
Have some courtesy,
Have some sympathy,
And some taste.
Use all your well-learned politesse,
Or I'll lay your soul to waste.
#10
Posted 08 June 2010 - 10:42 AM
Eh...
AirplaneChange apc = new AirplaneChange(); apc.method();
My advice: buy a book
Thank you
I'm done with the damn thing next week. Probably won't touch Java after that...
If you meet me:
Have some courtesy,
Have some sympathy,
And some taste.
Use all your well-learned politesse,
Or I'll lay your soul to waste.
#11
Posted 23 June 2010 - 04:43 AM
World Domination Status: ▾2.7%
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users