{"id":626,"date":"2016-02-15T09:27:36","date_gmt":"2016-02-15T14:27:36","guid":{"rendered":"https:\/\/fieldscience.cs.earlham.edu\/?p=626"},"modified":"2016-02-15T09:27:36","modified_gmt":"2016-02-15T14:27:36","slug":"best-method-for-threads-in-android","status":"publish","type":"post","link":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/2016\/02\/best-method-for-threads-in-android\/","title":{"rendered":"Best method for threads in Android"},"content":{"rendered":"<p>The past week I worked on making the classes that pertain to sensor sampling platforms more generic. Previously, I had been working on just getting them working using the Built-In sensor sampling fragment. The Built-In fragment uses the built in android sensors on the hardware device which uses the Android Sensor class. The aSensor class and other similar classes that we are going to use for all sensor platforms (Database reading and writing, sensor sample fragment frame, and the list adapter) were using Android Sensor class methods. I worked on getting rid of those methods and replacing them with more generic methods that can be used for all sensor sampling types.<\/p>\n<p>I have also been researching the best method for creating a thread in android classes. The SQLite work I&#8217;ve been doing is almost finished except it&#8217;s writing to the database too quickly which is making my primary keys fail. I am looking for best practices for writing to a database in a thread. In Seshat (our old application), we had a feature where the user could select how often they wanted to write to the database (in seconds). I plan to move this feature to Field Day but I want to research the best approach. In Seshat, we used a runOnUiThread method. This may be the best approach but there are other options to consider &#8212; Service, AsyncTask, Handler, Runnable, etc.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The past week I worked on making the classes that pertain to sensor sampling platforms more generic. Previously, I had been working on just getting them working using the Built-In sensor sampling fragment. The Built-In fragment uses the built in &hellip; <a href=\"https:\/\/fieldscience.cs.earlham.edu\/index.php\/2016\/02\/best-method-for-threads-in-android\/\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"kt_blocks_editor_width":"","footnotes":""},"categories":[1,11],"tags":[15,27,14,16,53,51],"class_list":["post-626","post","type-post","status-publish","format-standard","hentry","category-kristin","category-progress-reports","tag-android","tag-application","tag-design","tag-development","tag-fieldday","tag-software-architecture"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Best method for threads in Android - fieldscience @ earlham<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fieldscience.cs.earlham.edu\/index.php\/2016\/02\/best-method-for-threads-in-android\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Best method for threads in Android - fieldscience @ earlham\" \/>\n<meta property=\"og:description\" content=\"The past week I worked on making the classes that pertain to sensor sampling platforms more generic. Previously, I had been working on just getting them working using the Built-In sensor sampling fragment. The Built-In fragment uses the built in &hellip; Read More\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fieldscience.cs.earlham.edu\/index.php\/2016\/02\/best-method-for-threads-in-android\/\" \/>\n<meta property=\"og:site_name\" content=\"fieldscience @ earlham\" \/>\n<meta property=\"article:published_time\" content=\"2016-02-15T14:27:36+00:00\" \/>\n<meta name=\"author\" content=\"Kristin Muterspaw\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kristin Muterspaw\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/fieldscience.cs.earlham.edu\\\/index.php\\\/2016\\\/02\\\/best-method-for-threads-in-android\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fieldscience.cs.earlham.edu\\\/index.php\\\/2016\\\/02\\\/best-method-for-threads-in-android\\\/\"},\"author\":{\"name\":\"Kristin Muterspaw\",\"@id\":\"https:\\\/\\\/fieldscience.cs.earlham.edu\\\/#\\\/schema\\\/person\\\/2559340425ea97e18ee79c40f3365222\"},\"headline\":\"Best method for threads in Android\",\"datePublished\":\"2016-02-15T14:27:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fieldscience.cs.earlham.edu\\\/index.php\\\/2016\\\/02\\\/best-method-for-threads-in-android\\\/\"},\"wordCount\":240,\"commentCount\":0,\"keywords\":[\"android\",\"application\",\"design\",\"development\",\"fieldday\",\"software architecture\"],\"articleSection\":[\"Kristin\",\"Progress Reports\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/fieldscience.cs.earlham.edu\\\/index.php\\\/2016\\\/02\\\/best-method-for-threads-in-android\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fieldscience.cs.earlham.edu\\\/index.php\\\/2016\\\/02\\\/best-method-for-threads-in-android\\\/\",\"url\":\"https:\\\/\\\/fieldscience.cs.earlham.edu\\\/index.php\\\/2016\\\/02\\\/best-method-for-threads-in-android\\\/\",\"name\":\"Best method for threads in Android - fieldscience @ earlham\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fieldscience.cs.earlham.edu\\\/#website\"},\"datePublished\":\"2016-02-15T14:27:36+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/fieldscience.cs.earlham.edu\\\/#\\\/schema\\\/person\\\/2559340425ea97e18ee79c40f3365222\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fieldscience.cs.earlham.edu\\\/index.php\\\/2016\\\/02\\\/best-method-for-threads-in-android\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fieldscience.cs.earlham.edu\\\/index.php\\\/2016\\\/02\\\/best-method-for-threads-in-android\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fieldscience.cs.earlham.edu\\\/index.php\\\/2016\\\/02\\\/best-method-for-threads-in-android\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fieldscience.cs.earlham.edu\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Best method for threads in Android\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/fieldscience.cs.earlham.edu\\\/#website\",\"url\":\"https:\\\/\\\/fieldscience.cs.earlham.edu\\\/\",\"name\":\"fieldscience @ earlham\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/fieldscience.cs.earlham.edu\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/fieldscience.cs.earlham.edu\\\/#\\\/schema\\\/person\\\/2559340425ea97e18ee79c40f3365222\",\"name\":\"Kristin Muterspaw\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e7c298ecf2dd418cede9d8bbea149b1fd9aa9135a540aef28db205ac8749c8f2?s=96&d=wavatar&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e7c298ecf2dd418cede9d8bbea149b1fd9aa9135a540aef28db205ac8749c8f2?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e7c298ecf2dd418cede9d8bbea149b1fd9aa9135a540aef28db205ac8749c8f2?s=96&d=wavatar&r=g\",\"caption\":\"Kristin Muterspaw\"},\"url\":\"https:\\\/\\\/fieldscience.cs.earlham.edu\\\/index.php\\\/author\\\/kmmuterspaw\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Best method for threads in Android - fieldscience @ earlham","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/2016\/02\/best-method-for-threads-in-android\/","og_locale":"en_US","og_type":"article","og_title":"Best method for threads in Android - fieldscience @ earlham","og_description":"The past week I worked on making the classes that pertain to sensor sampling platforms more generic. Previously, I had been working on just getting them working using the Built-In sensor sampling fragment. The Built-In fragment uses the built in &hellip; Read More","og_url":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/2016\/02\/best-method-for-threads-in-android\/","og_site_name":"fieldscience @ earlham","article_published_time":"2016-02-15T14:27:36+00:00","author":"Kristin Muterspaw","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kristin Muterspaw","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/2016\/02\/best-method-for-threads-in-android\/#article","isPartOf":{"@id":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/2016\/02\/best-method-for-threads-in-android\/"},"author":{"name":"Kristin Muterspaw","@id":"https:\/\/fieldscience.cs.earlham.edu\/#\/schema\/person\/2559340425ea97e18ee79c40f3365222"},"headline":"Best method for threads in Android","datePublished":"2016-02-15T14:27:36+00:00","mainEntityOfPage":{"@id":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/2016\/02\/best-method-for-threads-in-android\/"},"wordCount":240,"commentCount":0,"keywords":["android","application","design","development","fieldday","software architecture"],"articleSection":["Kristin","Progress Reports"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fieldscience.cs.earlham.edu\/index.php\/2016\/02\/best-method-for-threads-in-android\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/2016\/02\/best-method-for-threads-in-android\/","url":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/2016\/02\/best-method-for-threads-in-android\/","name":"Best method for threads in Android - fieldscience @ earlham","isPartOf":{"@id":"https:\/\/fieldscience.cs.earlham.edu\/#website"},"datePublished":"2016-02-15T14:27:36+00:00","author":{"@id":"https:\/\/fieldscience.cs.earlham.edu\/#\/schema\/person\/2559340425ea97e18ee79c40f3365222"},"breadcrumb":{"@id":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/2016\/02\/best-method-for-threads-in-android\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fieldscience.cs.earlham.edu\/index.php\/2016\/02\/best-method-for-threads-in-android\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/2016\/02\/best-method-for-threads-in-android\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fieldscience.cs.earlham.edu\/"},{"@type":"ListItem","position":2,"name":"Best method for threads in Android"}]},{"@type":"WebSite","@id":"https:\/\/fieldscience.cs.earlham.edu\/#website","url":"https:\/\/fieldscience.cs.earlham.edu\/","name":"fieldscience @ earlham","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fieldscience.cs.earlham.edu\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/fieldscience.cs.earlham.edu\/#\/schema\/person\/2559340425ea97e18ee79c40f3365222","name":"Kristin Muterspaw","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/e7c298ecf2dd418cede9d8bbea149b1fd9aa9135a540aef28db205ac8749c8f2?s=96&d=wavatar&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/e7c298ecf2dd418cede9d8bbea149b1fd9aa9135a540aef28db205ac8749c8f2?s=96&d=wavatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e7c298ecf2dd418cede9d8bbea149b1fd9aa9135a540aef28db205ac8749c8f2?s=96&d=wavatar&r=g","caption":"Kristin Muterspaw"},"url":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/author\/kmmuterspaw\/"}]}},"_links":{"self":[{"href":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/wp-json\/wp\/v2\/posts\/626","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/wp-json\/wp\/v2\/comments?post=626"}],"version-history":[{"count":1,"href":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/wp-json\/wp\/v2\/posts\/626\/revisions"}],"predecessor-version":[{"id":627,"href":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/wp-json\/wp\/v2\/posts\/626\/revisions\/627"}],"wp:attachment":[{"href":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/wp-json\/wp\/v2\/media?parent=626"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/wp-json\/wp\/v2\/categories?post=626"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fieldscience.cs.earlham.edu\/index.php\/wp-json\/wp\/v2\/tags?post=626"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}