Antonio Alcorn Gong Chen Qianqian Lin

602 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
602
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Antonio Alcorn Gong Chen Qianqian Lin

  1. 1. Antonio Alcorn Gong Chen Qianqian Lin
  2. 2. Our Mission: ` To build out POSIT into a more ROBUST, user-friendly application
  3. 3. Our Mission:  To build out POSIT into a more ROBUST, user-friendly application
  4. 4. Refresher: What is Android?  Mobile Application Platform  Java based  Different applications based on Activity class  Applications run in own Unix process in own virtual machine
  5. 5. About POSIT ` Portable Open Search and Identification Tool  Built on the Google Android platform  Written by Prasanna Gautam, Trishan deLanerolle and Professor Ralph Morelli
  6. 6. Our Main Goals  Build out POSIT and turn it into a Robust Application  Build a better interface with the server  Allow the phone to synchronize well with the server  Build a more user-friendly interface  Change the architecture to MVC  Implement interface of ad hoc network
  7. 7. This Week: Tutorials  Database  Google maps  Camera  Gallery  GPS
  8. 8. NotePad v.1  Basic activity shell  Little functionality public class Notepadv1 extends ListActivity { ... /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.notepad_list); mDbHelper = new NotesDbAdapter(this); mDbHelper.open(); fillData(); } ...
  9. 9. NotePad v.2  Edit note content  Save in database public long createNote(String title, String body) { ContentValues initialValues = new ContentValues(); initialValues.put(KEY_TITLE, title); initialValues.put(KEY_BODY, body); return mDb.insert(DATABASE_TABLE, null, initialValues); } ... public boolean onCreateOptionsMenu(Menu menu) { ... menu.add(0, INSERT_ID,0, R.string.menu_insert); return true; }
  10. 10. NotePad v.3  Lifecycle management  Interruption doesn't crash, saves state  The “android way” private void createNote() { Intent i = new Intent(this, NoteEdit.class); startActivityForResult(i, ACTIVITY_CREATE); } ... @Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); fillData(); }
  11. 11. Tutorial: Gallery public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { ImageView i = new ImageView(mContext); i.setImageResource(mImageIds[position]); i.setLayoutParams(new Gallery.LayoutParams(150, 100)); i.setScaleType(ImageView.ScaleType.FIT_XY); i.setBackgroundResource(mGalleryItemBackground); return i;
  12. 12. Tutorial: Gallery cont public class ImageAdapter extends BaseAdapter { int mGalleryItemBackground; private Context mContext; private Integer[] mImageIds = { R.drawable.sample_1, R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4 };
  13. 13. Tutorial: Gallery cont public ImageAdapter(Context c) { mContext = c; /*TypedArray a = obtainStyledAttributes(android.R.styleable.Theme); mGalleryItemBackground = a.getResourceId( android.R.styleable.Theme_galleryItemBackground, 0); a.recycle();*/ }
  14. 14. Tutorial: Gallery cont public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { ImageView i = new ImageView(mContext); i.setImageResource(mImageIds[position]); i.setLayoutParams(new Gallery.LayoutParams(150, 100)); i.setScaleType(ImageView.ScaleType.FIT_XY); i.setBackgroundResource(mGalleryItemBackground); return i;
  15. 15. Tutorial: Map View  Allowuser to see  Allow user to create map and preset marker for self in markers current location
  16. 16. Tutorial: Map View cont. private void setCurrentGpsLocation(Location location) { if (location == null) { mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE); mLocationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 15000, 0, this); location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); } try { mLongitude = location.getLongitude(); mLatitude = location.getLatitude(); Log.i(TAG, "<long,lat> = <" + mLongitude + "," + mLatitude); Message msg = Message.obtain(); msg.what = UPDATE_LOCATION; HelloMapView.this.updateHandler.sendMessage(msg); } catch (NullPointerException e) { Log.i(TAG, "Null pointer exception " + mLongitude + "," + mLatitude); } }
  17. 17. Tutorial: Map View cont private void setCurrentGpsLocation(Location location) { if (location == null) { mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE); mLocationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 15000, 0, this); location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); } try { mLongitude = location.getLongitude(); mLatitude = location.getLatitude(); Log.i(TAG, "<long,lat> = <" + mLongitude + "," + mLatitude); Message msg = Message.obtain(); msg.what = UPDATE_LOCATION; HelloMapView.this.updateHandler.sendMessage(msg); } catch (NullPointerException e) { Log.i(TAG, "Null pointer exception " + mLongitude + "," + mLatitude); } }
  18. 18. Next Week:  Camera Tutorial  Start looking at POSIT  Small tasks in POSIT  Get acquainted with our phones!

×