/** Called when this activity becomes visible. */ @Override protected void onStart() { super.onStart(); ResponseHandler.register(mParkingPurchaseObserver); initializeOwnedItems(); }
/** Called when this activity is no longer visible. */ @Override protected void onStop() { super.onStop(); ResponseHandler.unregister(mParkingPurchaseObserver); }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.parkingpayment); mHandler = new Handler(); mParkingPurchaseObserver = new ParkingPurchaseObserver(mHandler); mBillingService = new BillingService(); mBillingService.setContext(this); mPurchaseDatabase = new PurchaseDatabase(DashboardActivity.myContext); // Get on the spot selected Intent starterIntent = getIntent(); Bundle bundle = starterIntent.getExtras(); TextView textAll = (TextView) findViewById(R.id.parkingAllDetailsTextView); /** Obtain time object * */ String timeObj = bundle.getString("time"); try { paidTime = Integer.parseInt(timeObj); Log.v(TAG, "Calculated time : " + paidTime); } catch (NumberFormatException nfe) { Log.v(TAG, "NumberFormatException: " + nfe.getMessage()); } /** Create parkingLocationObj */ String all = bundle.getString("info"); parkingLocationObj = LocationUtility.convertStringToObject(all); /** Use the object to populate fields */ String locAddress = "Address unavailable"; Geocoder geoCoder = new Geocoder(DashboardActivity.myContext, Locale.getDefault()); GeoPoint gp = new GeoPoint( (int) (parkingLocationObj.getLatitude() * 1E6), (int) (parkingLocationObj.getLongitude() * 1E6)); locAddress = LocationUtility.ConvertPointToLocation(gp, geoCoder); Log.v(TAG, "Setting address to: " + locAddress); parkingLocationObj.setAddress(locAddress); String typeToDisplay = parkingLocationObj.getType() == null ? "Not known" : "" + parkingLocationObj.getType(); textAll.setText( "\n" + "Address: " + parkingLocationObj.getAddress() + "\n" + "Type:" + typeToDisplay + "\n" + "MeterId: " + parkingLocationObj.getMeterID() + "\n" + "Number of Parking Spots at this location: " + parkingLocationObj.getQuantity() + "\n"); setupWidgets(); // Check if billing is supported. ResponseHandler.register(mParkingPurchaseObserver); if (!mBillingService.checkBillingSupported()) { showDialog(DIALOG_CANNOT_CONNECT_ID); } }