Search Results

Search found 21 results on 1 pages for 'lordsnoutimus'.

Page 1/1 | 1 

  • Null Validation on EditText box in Alert Dialog - Android

    - by LordSnoutimus
    Hi, I am trying to add some text validation to an edit text field located within an alert dialog box. It prompts a user to enter in a name. I want to add some validation so that if what they have entered is blank or null, it does not do anything apart from creating a Toast saying error. So far I have: AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Record New Track"); alert.setMessage("Please Name Your Track:"); // Set an EditText view to get user input final EditText trackName = new EditText(this); alert.setView(trackName); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String textString = trackName.getText().toString(); // Converts the value of getText to a string. if (textString != null && textString.trim().length() ==0) { Context context = getApplicationContext(); CharSequence error = "Please enter a track name" + textString; int duration = Toast.LENGTH_LONG; Toast toast = Toast.makeText(context, error, duration); toast.show(); } else { SQLiteDatabase db = waypoints.getWritableDatabase(); ContentValues trackvalues = new ContentValues(); trackvalues.put(TRACK_NAME, textString); trackvalues.put(TRACK_START_TIME,tracktimeidentifier ); insertid=db.insertOrThrow(TRACK_TABLE_NAME, null, trackvalues); } But this just closes the Alert Dialog and then displays the Toast. I want the Alert Dialog to still be on the screen. Thanks

    Read the article

  • Foreign key constraints in Android using SQLite? on Delete cascade.

    - by LordSnoutimus
    I have two tables: tracks and waypoints, a track can have many waypoints, but a waypoint is assigned to only 1 track. In the way points table I have a column called "trackidfk" which inserts the track_ID once a track is made, however I have not setup Foreign Key constraints on this column. When I delete a track I want to delete the assigned waypoints, is this possible?. I read about using Triggers but I don't think they are supported in Android. To create the waypoints table: public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + LONGITUDE + " INTEGER," + LATITUDE + " INTEGER," + TIME + " INTEGER,"+ TRACK_ID_FK + " INTEGER );");

    Read the article

  • Adding visible "Markers" to represent Geopoints to a MapView using ItemizedOverlay in Android

    - by LordSnoutimus
    Hello, I am building an application which stores GPS locations in a SQLite database and then outputs the data onto a MapView using an Overlay by drawing a red line between the points. I want to be able to show graphical markers (images) for each of these points as well as the red line. My code is as follows: public class MyOverlay extends ItemizedOverlay { // private Projection projection; private Paint linePaint; private Vector points; public MyOverlay(Drawable defaultMarker) { super(defaultMarker); points = new Vector<GeoPoint>(); //set colour, stroke width etc. linePaint = new Paint(); linePaint.setARGB(255, 255, 0, 0); linePaint.setStrokeWidth(3); linePaint.setDither(true); linePaint.setStyle(Style.FILL); linePaint.setAntiAlias(true); linePaint.setStrokeJoin(Paint.Join.ROUND); linePaint.setStrokeCap(Paint.Cap.ROUND); } public void addPoint(GeoPoint point) { populate(); points.addElement(point); } //public void setProjection(Projection projection) { // this.projection = projection; // } public void draw(Canvas canvas, MapView view, boolean shadow) { populate(); int size = points.size(); Point lastPoint = new Point(); if(size == 0) return; view.getProjection().toPixels(points.get(0), lastPoint); Point point = new Point(); for(int i = 1; i<size; i++){ view.getProjection().toPixels(points.get(i), point); canvas.drawLine(lastPoint.x, lastPoint.y, point.x, point.y, linePaint); lastPoint = point; } } @Override protected OverlayItem createItem(int arg0) { // TODO Auto-generated method stub return null; } @Override public int size() { // TODO Auto-generated method stub return 0; } } What would be the easiest way to implement adding markers for each GeoPoint? Thanks

    Read the article

  • Overlay only draws line between first 2 GPS points in Android

    - by LordSnoutimus
    Hi, I am experiencing an unusual error using ItemizedOverlay in Android. I am creating a GPS tracking device that plots a route between waypoints stored in a database. When I provide the first two sets of longitude and latitude points through the emulator in Eclipse, it draws a red line just how I want it, but if I send another GPS point, it animates to the point, but does not draw a line from the last point. public class MyOverlay extends ItemizedOverlay { // private Projection projection; private Paint linePaint; private Vector points; public MyOverlay(Drawable defaultMarker) { super(defaultMarker); points = new Vector<GeoPoint>(); //set colour, stroke width etc. linePaint = new Paint(); linePaint.setARGB(255, 255, 0, 0); linePaint.setStrokeWidth(3); linePaint.setDither(true); linePaint.setStyle(Style.FILL); linePaint.setAntiAlias(true); linePaint.setStrokeJoin(Paint.Join.ROUND); linePaint.setStrokeCap(Paint.Cap.ROUND); } public void addPoint(GeoPoint point) { points.addElement(point); } public void draw(Canvas canvas, MapView view, boolean shadow) { int size = points.size(); Point lastPoint = new Point(); if(size == 0) return; view.getProjection().toPixels(points.get(0), lastPoint); Point point = new Point(); for(int i = 1; i<size; i++){ view.getProjection().toPixels(points.get(i), point); canvas.drawLine(lastPoint.x, lastPoint.y, point.x, point.y, linePaint); lastPoint = point; } } @Override protected OverlayItem createItem(int arg0) { // TODO Auto-generated method stub return null; } @Override public int size() { // TODO Auto-generated method stub return 0; } }

    Read the article

  • Easiest way to export a route stored in a SQLite database to a file so it can be imported to a Googl

    - by LordSnoutimus
    Hello, I have created an application that records a series of longitude and latitude values in a SQLite database and display them as a coloured track on a MapActivity. I now want to be able to export this data somehow (preferably to a file) so a user can upload the values to a website showing a Google Map API. My question is: what would be the quickest way to export the data (and in what file format: GPX, XML, CSV) to the SD card located on the Android device. Many thanks.

    Read the article

  • Finding the distance between 2 points in Android using Cursor and the distanceTo() method

    - by LordSnoutimus
    Hello, I am trying to calculate the distance between the first GPS point stored in a SQLite database and the last GPs point stored. My code so far is this: private double Distance() { SQLiteDatabase db1 = waypoints.getWritableDatabase(); Cursor cursor = db1.query(TABLE_NAME, FROM, null, null, null, null,ORDER_BY); Cursor cursor1 = db1.query(TABLE_NAME, FROM, null, null, null, null,ORDER_BY); Double lat = cursor.getDouble(2); Double lon = cursor.getDouble(1); cursor.moveToFirst(); cursor.moveToLast(); cursor.close(); distance = cursor.distanceTo(cursor1); } I realise I need to return a value but the error I am receiving is for the distanceTo method "The method distanceTo(Cursor) is undefined for the type Cursor" Thanks.

    Read the article

  • How long should it take for someone to be able to type code from memory?

    - by LordSnoutimus
    Hi, I understand that this question could be answered with a simple sentence and that it may be viewed as subjective, however, I am a young student who is interested in pursuing a career in programming and wondered how long it took some of you to get to the level of experience you are now?. I ask this because I am currently working on building an application in Java on the Android platform and it bothers me that I am constantly having to look up how to write a certain section of code in my application such as writing to a database, or how the if loop should be structured. My question really is, how long did it take for you to become experienced enough to actually know exactly how your next line of code was going to look, before you even wrote it?

    Read the article

  • Overlay only draws between first 2 points in Android

    - by LordSnoutimus
    Hi, I am experiencing an unusual error using ItemizedOverlay in Android. I am creating a GPS tracking device that plots a route between waypoints stored in a database. When I provide the first two sets of longitude and latitude points through the emulator in Eclipse, it draws a red line just how I want it, but if I send another GPS point, it animates to the point, but does not draw a line from the last point. public class MyOverlay extends ItemizedOverlay { // private Projection projection; private Paint linePaint; private Vector points; public MyOverlay(Drawable defaultMarker) { super(defaultMarker); points = new Vector<GeoPoint>(); //set colour, stroke width etc. linePaint = new Paint(); linePaint.setARGB(255, 255, 0, 0); linePaint.setStrokeWidth(3); linePaint.setDither(true); linePaint.setStyle(Style.FILL); linePaint.setAntiAlias(true); linePaint.setStrokeJoin(Paint.Join.ROUND); linePaint.setStrokeCap(Paint.Cap.ROUND); } public void addPoint(GeoPoint point) { points.addElement(point); } public void draw(Canvas canvas, MapView view, boolean shadow) { int size = points.size(); Point lastPoint = new Point(); if(size == 0) return; view.getProjection().toPixels(points.get(0), lastPoint); Point point = new Point(); for(int i = 1; i<size; i++){ view.getProjection().toPixels(points.get(i), point); canvas.drawLine(lastPoint.x, lastPoint.y, point.x, point.y, linePaint); lastPoint = point; } } @Override protected OverlayItem createItem(int arg0) { // TODO Auto-generated method stub return null; } @Override public int size() { // TODO Auto-generated method stub return 0; } }

    Read the article

  • Cursor while loop returning every value but the last

    - by LordSnoutimus
    Hello, I am using a while loop to iterate through a cursor and then outputing the longitude and latitude values of every point within the database. For some reason it is not returning the last (or first depending on if I use Cursor.MoveToLast) set of longitude and latitude values in the cursor. Here is my code: public void loadTrack() { SQLiteDatabase db1 = waypoints.getWritableDatabase(); Cursor trackCursor = db1.query(TABLE_NAME, FROM, "trackidfk=1", null, null, null,ORDER_BY); trackCursor.moveToFirst(); while (trackCursor.moveToNext()) { Double lat = trackCursor.getDouble(2); Double lon = trackCursor.getDouble(1); //overlay.addGeoPoint( new GeoPoint( (int)(lat*1E6), (int)(lon*1E6))); System.out.println(lon); System.out.println(lat); } } From this I am getting: 04-02 15:39:07.416: INFO/System.out(10551): 3.0 04-02 15:39:07.416: INFO/System.out(10551): 5.0 04-02 15:39:07.416: INFO/System.out(10551): 4.0 04-02 15:39:07.416: INFO/System.out(10551): 5.0 04-02 15:39:07.416: INFO/System.out(10551): 5.0 04-02 15:39:07.416: INFO/System.out(10551): 5.0 04-02 15:39:07.416: INFO/System.out(10551): 4.0 04-02 15:39:07.416: INFO/System.out(10551): 4.0 04-02 15:39:07.416: INFO/System.out(10551): 3.0 04-02 15:39:07.416: INFO/System.out(10551): 3.0 04-02 15:39:07.416: INFO/System.out(10551): 2.0 04-02 15:39:07.416: INFO/System.out(10551): 2.0 04-02 15:39:07.493: INFO/System.out(10551): 1.0 04-02 15:39:07.493: INFO/System.out(10551): 1.0 7 Sets of values, where I should be getting 8 sets. Thanks.

    Read the article

  • Easiest way to export longitude and latitude data stored in a SQLite database to a file so it can be

    - by LordSnoutimus
    Hello, I have created an application that records a series of longitude and latitude values in a SQLite database and display them as a coloured track on a MapActivity. I now want to be able to export this data somehow (preferably to a file) so a user can upload the values to a website showing a Google Map API. My question is: what would be the quickest way to export the data (and in what file format: GPX, XML, CSV) to the SD card located on the Android device. Many thanks.

    Read the article

  • Receiving a NullPointerException when calling a cursor in Android

    - by LordSnoutimus
    I am creating an application which tracks the users location using GPS, stores the longitude and latitude in a database using a content provider then output the first long and lat to a mapview. I am able to create the cursor using this line of code: Cursor c = getContentResolver().query(GPSContentProvider.CONTENT_URI, null, null, null, null); startManagingCursor(c); However, when I make a call to move to the first row in the database or even try to close the cursor using c.close(); I receive a NullPointerException.

    Read the article

  • Using a Context Menu to delete from a SQLite database in Android

    - by LordSnoutimus
    Hi, I have created a list view that displays the names and dates of items stored in a SQLite database, now I want to use a Context Menu to modify these items stored in the database such as edit the name, delete, and view. This is the code for the list view: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listview); SQLiteDatabase myDB = null; myDB = this.openOrCreateDatabase(MY_DB_NAME, MODE_PRIVATE, null); Cursor cur = myDB.rawQuery("SELECT _id, trackname, tracktime" + " FROM " + MY_DB_TABLE, null); ListAdapter adapter = new SimpleCursorAdapter(this, R.layout.listview, cur, new String[] { Constants.TRACK_NAME, Constants.TRACK_TIME}, new int[] { R.id.text1, R.id.text2}); ListView list = (ListView)findViewById(R.id.list); list.setAdapter(adapter); registerForContextMenu(list); } and the Context Menu... public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.setHeaderTitle("Track Options"); menu.add(0, CHANGE_NAME, 0, "Change name"); menu.add(0, VIEW_TRACK, 0, "View track"); menu.add(0, SEND_TRACK, 0, "Send track"); menu.add(0, DELETE_TRACK, 0, "Delete track"); } I have used a Switch statement to control the menu items.. public boolean onContextItemSelected(MenuItem item) { switch (item.getItemId()){ case CHANGE_NAME: changename(); return true; case DELETE_TRACK: deletetrack(); return true; default: return super.onContextItemSelected(item); } So how would I go ahead and map the deletetrack(); method to find the ID of the track stored in the database to the item that has been selected in the list view?

    Read the article

  • Connecting GPS coordinates taken from a database in Android using Overlay

    - by LordSnoutimus
    I am currently building an application that allows users to track where their phone has been on a Google Map. At the moment, when the onLocationChanged() method is called, the application stores the current GPS longitude and latitude in a database and calls the animateTo() method to the current position. Using SDK 1.5, how would I go about connecting these points with a coloured line drawn on the MapView using an Overlay?.

    Read the article

  • Displaying Longitude and Latitude values stored in a SQLite db as a Route on a MapView in Android (N

    - by LordSnoutimus
    I am currently in the process of creating an application that records current location of a mobile device in intervals, displaying the route as a coloured line on the device in real-time. At the same time the application is storing the longitude and latitude in a SQLite database as I want the user to be able to bring up that specific route again. The route has a primary key and each waypoint is linked to that route by a foreign key. What would be the easiest way to display the saved route on the map?.

    Read the article

1