vyoumans

Android class... crashing around 107

Dec 27th, 2013
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.05 KB | None | 0 0
  1. package com.techlatin.loge;
  2.  
  3. import android.content.Context;
  4. import android.content.Intent;
  5. import android.graphics.Color;
  6. import android.location.Location;
  7. import android.location.LocationListener;
  8. import android.location.LocationManager;
  9. import android.support.v7.app.ActionBarActivity;
  10. import android.support.v7.app.ActionBar;
  11. import android.support.v4.app.Fragment;
  12. import android.os.Bundle;
  13. import android.view.LayoutInflater;
  14. import android.view.Menu;
  15. import android.view.MenuItem;
  16. import android.view.View;
  17. import android.view.ViewGroup;
  18. import android.os.Build;
  19. import android.widget.Button;
  20. import android.widget.TextView;
  21.  
  22. public class ZZE_NewLocations extends ActionBarActivity {
  23.  
  24. String session_id;
  25. String session_name;
  26.  
  27. String Lat;
  28. String Lng;
  29. String zzBINIDQR;
  30.  
  31. String ErrorText;
  32. Boolean thereWasAnError = false;
  33.  
  34.  
  35.  
  36. @Override
  37. protected void onCreate(Bundle savedInstanceState) {
  38. super.onCreate(savedInstanceState);
  39. setContentView(R.layout.activity_zze__new_locations);
  40.  
  41. if (savedInstanceState == null) {
  42. getSupportFragmentManager().beginTransaction()
  43. .add(R.id.container, new PlaceholderFragment())
  44. .commit();
  45. }
  46. }
  47.  
  48.  
  49. @Override
  50. public boolean onCreateOptionsMenu(Menu menu) {
  51.  
  52. // Inflate the menu; this adds items to the action bar if it is present.
  53. getMenuInflater().inflate(R.menu.zze__new_locations, menu);
  54. return true;
  55. }
  56.  
  57. @Override
  58. public boolean onOptionsItemSelected(MenuItem item) {
  59. // Handle action bar item clicks here. The action bar will
  60. // automatically handle clicks on the Home/Up button, so long
  61. // as you specify a parent activity in AndroidManifest.xml.
  62. int id = item.getItemId();
  63. if (id == R.id.action_settings) {
  64. return true;
  65. }
  66. return super.onOptionsItemSelected(item);
  67. }
  68.  
  69. /**
  70. * A placeholder fragment containing a simple view.
  71. */
  72. public static class PlaceholderFragment extends Fragment {
  73.  
  74. public PlaceholderFragment() {
  75. }
  76.  
  77. @Override
  78. public View onCreateView(LayoutInflater inflater, ViewGroup container,
  79. Bundle savedInstanceState) {
  80. View rootView = inflater.inflate(R.layout.fragment_zze__new_locations, container, false);
  81. return rootView;
  82. }
  83. }
  84.  
  85. //==========================================================
  86.  
  87. private boolean resumeHasRun = false;
  88. @Override
  89. protected void onResume(){
  90.  
  91. //Button btnst01 = (Button) findViewById(R.id.btnStep1_submit);
  92. //btnst01.setEnabled(false);
  93.  
  94. super.onResume();
  95. if (!resumeHasRun){
  96. resumeHasRun = true;
  97. //return;
  98. }
  99. // get the session stuff here
  100.  
  101. Bundle extras = getIntent().getExtras();
  102. if (extras != null) {
  103. session_id = extras.getString("session_id");
  104. session_name = extras.getString("session_name");
  105.  
  106. }
  107.  
  108. final TextView xxSESSION_NAME = (TextView) findViewById(R.id.tvSESSION_NAME01);
  109. xxSESSION_NAME.setText(session_name);
  110.  
  111. final TextView xxSESSION_ID = (TextView) findViewById(R.id.tvSESSION_ICD01);
  112. xxSESSION_ID.setText(session_id);
  113.  
  114.  
  115. Do_WHATABOUT_ZZE();
  116.  
  117. }
  118.  
  119. private void Do_WHATABOUT_ZZE(){
  120. // will explain what this screen is about
  121. TextView tv_zze_WhatAbout = (TextView) findViewById(R.id.tv_ZZE_WHAT_ABOUT);
  122. tv_zze_WhatAbout.setText("This screen is for NEW deployments of Existing and New Assets. You should use this screen only ONCE per Asset.");
  123. }
  124.  
  125.  
  126.  
  127.  
  128. //====================================================================================
  129.  
  130. public void btnClickZZBGetLatLong (View view){
  131. locStartListener();
  132. }
  133.  
  134. public void locStartListener(){
  135. // Acquire a reference to the system Location Manager
  136. LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
  137.  
  138. // Define a listener that responds to location updates
  139. LocationListener locationListener = new LocationListener() {
  140. TextView xxLat = (TextView) findViewById(R.id.tvLat);
  141. TextView xxLong = (TextView) findViewById(R.id.tvLng);
  142.  
  143. public void onLocationChanged(Location location) {
  144. // Called when a new location is found by the network location provider.
  145. //makeUseOfNewLocation(location);
  146.  
  147. location.getLatitude();
  148. location.getLongitude();
  149.  
  150. //xxLat.setText( location.getLatitude().toString() );
  151. xxLat.setText( String.valueOf(location.getLatitude()) );
  152. xxLat.setBackgroundColor(Color.GREEN);
  153. xxLong.setText(String.valueOf(location.getLongitude()));
  154. xxLong.setBackgroundColor(Color.GREEN);
  155.  
  156. Lat = xxLat.getText().toString();
  157. Lng = xxLong.getText().toString();
  158.  
  159. //Button btnst02 = (Button) findViewById(R.id.btnStep2_submit);
  160. //btnst02.setEnabled(true);
  161. }
  162.  
  163. public void onStatusChanged(String provider, int status, Bundle extras) {}
  164.  
  165. public void onProviderEnabled(String provider) {}
  166.  
  167. public void onProviderDisabled(String provider) {}
  168. };
  169.  
  170. // Register the listener with the Location Manager to receive location updates
  171. //locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
  172. locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
  173.  
  174. }
  175.  
  176.  
  177.  
  178. //================================================================
  179. //QRCode Reading
  180.  
  181.  
  182. public void btnZZZB_STEP01_SCAN01_click (View view){
  183. Intent intent = new Intent("com.google.zxing.client.android.SCAN");
  184. //intent.putExtra("SCAN_MODE", "PRODUCT_MODE");//for Qr code, its "QR_CODE_MODE" instead of "PRODUCT_MODE"
  185. intent.putExtra("SCAN_MODE", "QR_CODE_MODE");//for Qr code, its "QR_CODE_MODE" instead of "PRODUCT_MODE"
  186. intent.putExtra("SAVE_HISTORY", false);//this stops saving ur barcode in barcode scanner app's history
  187. startActivityForResult(intent, 0);
  188. }
  189.  
  190.  
  191. @Override
  192. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  193. super.onActivityResult(requestCode, resultCode, data);
  194. if (requestCode == 0) {
  195. if (resultCode == RESULT_OK) {
  196. //String contents = data.getStringExtra("SCAN_RESULT"); //this is the result
  197.  
  198. // zzBINIDQR = data.getStringExtra("SCAN_RESULT");
  199.  
  200.  
  201. // TextView tvtest000 = (TextView) findViewById(R.id.tvBINID_QR);
  202. // tvtest000.setText(BINID_QR);
  203. // tvtest000.setBackgroundColor(Color.GREEN);
  204.  
  205. //BINID_QR = contents;
  206.  
  207. //Button btnst01a = (Button) findViewById(R.id.btnStep1_submit);
  208. //btnst01.setEnabled(true);
  209.  
  210. }
  211. else if (resultCode == RESULT_CANCELED) {
  212. // Handle cancel
  213. //Button btnst01 = (Button) findViewById(R.id.btnStep1_submit);
  214. //btnst01.setEnabled(false);
  215.  
  216. zzBINIDQR = "--- no result ---";
  217.  
  218.  
  219. // TextView tvtest000 = (TextView) findViewById(R.id.tvBINID_QR);
  220. // tvtest000.setText(BINID_QR);
  221. // tvtest000.setBackgroundColor(Color.RED);
  222.  
  223. }
  224. }
  225. }
  226.  
  227.  
  228.  
  229. //======================== FRAGMENTS ===============================
  230. public void btnClick_zze_01__loc_id(View view){
  231.  
  232. setContentView(R.layout.fragment_zze_01__loc_id);
  233.  
  234. }
  235.  
  236.  
  237.  
  238.  
  239. //======================== FRAGMENTS ===============================
  240. public void btnClick_zze_09__return(View view){
  241.  
  242. setContentView(R.layout.fragment_zze__new_locations);
  243.  
  244. }
  245.  
  246.  
  247. }
Advertisement
Add Comment
Please, Sign In to add comment