@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    Location l = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    if (l == null) {
      l = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    }

    final GeoPoint point;
    if (l != null) {
      point = new GeoPoint(l.getLatitude(), l.getLongitude());
    } else {
      final Intent intent = getIntent();
      double lat =
          intent.getDoubleExtra(MapsConstants.EXTRA_LATITUDE, MapsConstants.DEFAULT_LATIUDE);
      double lon =
          intent.getDoubleExtra(MapsConstants.EXTRA_LONGITUDE, MapsConstants.DEFAULT_LONGITUDE);
      point = new GeoPoint(lat, lon);
    }

    mOverlay = new BubbleClickableOverlay(this, point);
    getMapView().getOverlays().add(mOverlay);
  }
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   if (resultCode == Activity.RESULT_OK) {
     if (requestCode == REQUEST_CODE_CAMERA) { // 发送照片
       if (cameraFile != null && cameraFile.exists())
         sendImageMessage(cameraFile.getAbsolutePath());
     } else if (requestCode == REQUEST_CODE_LOCAL) { // 发送本地图片
       if (data != null) {
         Uri selectedImage = data.getData();
         if (selectedImage != null) {
           sendPicByUri(selectedImage);
         }
       }
     } else if (requestCode == REQUEST_CODE_MAP) { // 地图
       double latitude = data.getDoubleExtra("latitude", 0);
       double longitude = data.getDoubleExtra("longitude", 0);
       String locationAddress = data.getStringExtra("address");
       if (locationAddress != null && !locationAddress.equals("")) {
         sendLocationMessage(latitude, longitude, locationAddress);
       } else {
         Toast.makeText(getActivity(), R.string.unable_to_get_loaction, 0).show();
       }
     }
   }
 }
Beispiel #3
1
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map);

    // Inflates the action bar
    ActionBar bar = getActionBar();
    bar.hide();

    // Makes sure Google Play Services are installed
    int checkGooglePlayServices = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

    // Get the intent and sees if there is a starting coordinate value.  If not, assigns general
    // Toronto coordinates
    intent = getIntent();
    lat = intent.getDoubleExtra(HomeActivity.latName, 43.6481);
    lon = intent.getDoubleExtra(HomeActivity.lonName, -79.4042);
    coords = new LatLng(lat, lon);

    // Checks if GooglePlayServices are installed, informs the user if they're not
    if (checkGooglePlayServices != ConnectionResult.SUCCESS) {
      Toast.makeText(getBaseContext(), "Google Play Services not installed", Toast.LENGTH_LONG)
          .show();
    } else {
      setUpMapIfNeeded();
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.second);
    setTitle("Second Activity");

    Intent inIntent = getIntent();
    String calc = inIntent.getStringExtra("calc");
    final double first = inIntent.getDoubleExtra("first", 0);
    final double second = inIntent.getDoubleExtra("second", 0);
    final double result;
    Button ret = (Button) findViewById(R.id.ret);

    if (calc.equals("plus")) result = Double.parseDouble(String.format("%.3f", first + second));
    else if (calc.equals("minus"))
      result = Double.parseDouble(String.format("%.3f", first - second));
    else if (calc.equals("multiply"))
      result = Double.parseDouble(String.format("%.3f", first * second));
    else if (calc.equals("divider"))
      result = Double.parseDouble(String.format("%.3f", first / second));
    else result = 0;

    ret.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent outIntent = new Intent(getApplicationContext(), MainActivity.class);
            outIntent.putExtra("result", result);
            setResult(RESULT_OK, outIntent);
            finish();
          }
        });
  }
Beispiel #5
1
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    instance = this;
    // Gl app = (Gl)this.getApplication();
    if (mBMapManager == null) {
      initEngineManager(this.getApplicationContext());
    }
    setContentView(R.layout.activity_baidumap);
    mMapView = (MapView) findViewById(R.id.bmapView);
    mMapController = mMapView.getController();
    sendButton = (Button) findViewById(R.id.btn_location_send);
    initMapView();

    mMapView.getController().setZoom(17);
    mMapView.getController().enableClick(true);
    mMapView.setBuiltInZoomControls(true);
    Intent intent = getIntent();
    double latitude = intent.getDoubleExtra("latitude", 0);
    if (latitude == 0) {
      showMapWithLocationClient();
    } else {
      double longtitude = intent.getDoubleExtra("longitude", 0);
      String address = intent.getStringExtra("address");
      showMap(latitude, longtitude, address);
    }
  }
  @Override
  public void onReceive(Context context, Intent intent) {

    double lat = intent.getDoubleExtra(DOUBLE_LATITUDE, 0);
    double lng = intent.getDoubleExtra(DOUBLE_LONGITUDE, 0);

    callback.returnNewLocation(lat, lng);
  }
Beispiel #7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_crumb);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Register your receiver so that the Activity can be notified
    // when the JSON response came back
    IntentFilter filter = new IntentFilter(MyRequestReceiver6.PROCESS_RESPONSE);
    filter.addCategory(Intent.CATEGORY_DEFAULT);
    receiver = new MyRequestReceiver6();
    registerReceiver(receiver, filter);

    // get references to the EditText, TextView and toggle fields
    crumbName = (EditText) findViewById(R.id.editcrumb_name);
    crumbComment = (EditText) findViewById(R.id.editcrumb_description);
    crumbTags = (EditText) findViewById(R.id.editcrumb_tags);
    toggle = (ToggleButton) findViewById(R.id.toggleButton2);

    isPrivate = getIntent().getBooleanExtra(MyCrumbsActivity.CRUMB_PRIVATE, true);
    if (isPrivate) toggle.setChecked(true);
    else toggle.setChecked(false);

    // populate EditTexts and TextViews  fields with selected crumb attributes
    Intent intent3 = getIntent();
    crumbName.setText(intent3.getStringExtra(MyCrumbsActivity.CRUMB_NAME));
    crumbComment.setText(intent3.getStringExtra(MyCrumbsActivity.CRUMB_COMMENT));
    crumbTags.setText(intent3.getStringExtra(MyCrumbsActivity.CRUMB_TAGS));

    // get longitude and latitude of crumb to edit to mark on map fragment
    longitude = intent3.getDoubleExtra(MyCrumbsActivity.CRUMB_LONGITUDE, 0.0);
    latitude = intent3.getDoubleExtra(MyCrumbsActivity.CRUMB_LATITUDE, 0.0);

    // setup Google map to mark where crumb is
    SupportMapFragment supportMapFragment =
        (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    map = supportMapFragment.getMap();

    // get location of crumb, set to a LatLng object
    LatLng location = new LatLng(latitude, longitude);

    // mark crumb location on map
    map.setMyLocationEnabled(true);
    map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    map.moveCamera(CameraUpdateFactory.newLatLng(location));
    map.animateCamera(CameraUpdateFactory.zoomTo(14));
    map.addMarker(
        new MarkerOptions()
            .position(location)
            .title(intent3.getStringExtra(MyCrumbsActivity.CRUMB_NAME)));
    CameraUpdate yourLocation = CameraUpdateFactory.newLatLngZoom(location, 12);
    map.animateCamera(yourLocation);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_work_mapping_activity);
    //
    Intent recieve = getIntent();
    buildingImg = recieve.getByteArrayExtra("img");
    z = recieve.getDoubleExtra("z", 0);
    scale = recieve.getDoubleExtra("scale", 0.05);
    savedPoint = new xy();
    curPoint = new xy();
    //
    getWindowSize();
    drawer = (SlidingDrawer) findViewById(R.id.activity_work_mapping_drawer);
    menulayer =
        (LinearLayout) findViewById(R.id.activity_work_mapping_draggable_containmenubuttonlayout);
    map_frame = (FrameLayout) findViewById(R.id.activity_work_mapping_draggable_frame);
    DimageView = (DraggableImageView) findViewById(R.id.activity_work_mapping_draggable_imageview);
    //
    BitmapFactory.Options option = new BitmapFactory.Options();
    option.inScaled = false;
    //

    Bitmap backgroudImage = getMapBitmap(option);
    createOverlayView(backgroudImage.getWidth(), backgroudImage.getHeight(), backgroudImage);
    setImageHandler();
    DimageView.setHandler(handler);
    DimageView.setDmetric(getDispaymetric());
    DimageView.setImageBitmap(backgroudImage);
    arr_button_menu = new Button[8];

    measureCheckBox = (CheckBox) findViewById(R.id.activity_work_mapping_drawer_check_measure);
    measureCheckBox.setOnCheckedChangeListener(checkboxListener);
    measureCheckBox.setTag(1);
    measureCheckBox.setChecked(true);
    poiCheckBox = (CheckBox) findViewById(R.id.activity_work_mapping_drawer_check_poi);
    poiCheckBox.setOnCheckedChangeListener(checkboxListener);
    poiCheckBox.setTag(2);
    poiCheckBox.setChecked(true);
    wayCheckBox = (CheckBox) findViewById(R.id.activity_work_mapping_drawer_check_way);
    wayCheckBox.setOnCheckedChangeListener(checkboxListener);
    wayCheckBox.setTag(3);
    wayCheckBox.setChecked(true);
    UpdateButton = (Button) findViewById(R.id.activity_work_mapping_drawer_button_update);
    UpdateButton.setOnClickListener(l);

    createPOIInputDialog();
    createMeasureDialog();
    setInputHandler();

    init();
  }
  @Override
  protected void onResume() {
    super.onResume();
    Intent intent = getIntent();
    if (intent != null) {
      double lat = intent.getDoubleExtra(SEARCH_LAT, 0);
      double lon = intent.getDoubleExtra(SEARCH_LON, 0);
      if (lat != 0 || lon != 0) {
        location = new LatLon(lat, lon);
      }
    }
    if (location == null && getParent() instanceof SearchActivity) {
      location = ((SearchActivity) getParent()).getSearchPoint();
    }
    if (location == null) {
      location = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
    }

    List<HistoryEntry> historyEntries = helper.getHistoryEntries(this);

    getListView().removeFooterView(clearButton);
    if (!historyEntries.isEmpty()) {
      getListView().addFooterView(clearButton);
    }
    setListAdapter(new HistoryAdapter(historyEntries));
  }
 @Override
 protected void onResume() {
   super.onResume();
   selectAddress = getIntent() != null && getIntent().getBooleanExtra(SELECT_ADDRESS, false);
   setOnItemClickListener(
       new AdapterView.OnItemClickListener() {
         @Override
         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
           T repo = getListAdapter().getItem(position);
           itemSelectedBase(repo, view);
         }
       });
   Intent intent = getIntent();
   if (intent != null) {
     if (intent.hasExtra(SearchActivity.SEARCH_LAT)
         && intent.hasExtra(SearchActivity.SEARCH_LON)) {
       double lat = intent.getDoubleExtra(SearchActivity.SEARCH_LAT, 0);
       double lon = intent.getDoubleExtra(SearchActivity.SEARCH_LON, 0);
       locationToSearch = new LatLon(lat, lon);
     }
   }
   if (locationToSearch == null) {
     locationToSearch = settings.getLastKnownMapLocation();
   }
 }
Beispiel #11
0
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
    // In base al tipo di intent che arriva faccio azioni diverse
    if (intent.getBooleanExtra(PLAY, false)) {
      message = intent.getStringExtra(UI1.EXTRA_MESSAGE);
      if (!sessionName.equals(message)) {
        stop();
      }
      sessionName = message;
      play();
    }
    if (intent.getBooleanExtra(PAUSE, false)) pause();

    if (intent.getBooleanExtra(ECHO, false)) {
      echo();
    }
    if (intent.getBooleanExtra(VOLUME, false)) {
      boolean up = intent.getBooleanExtra("up", false);
      double volume = intent.getDoubleExtra("volume", 0.0);
      volume(up, volume);
    }
    if (intent.getBooleanExtra(SPEED, false)) {
      boolean up = intent.getBooleanExtra("up", false);
      int intensity = intent.getIntExtra("intensity", -1);
      speed(up, intensity);
    }

    if (intent.getBooleanExtra(DELAY, false)) {
      delay();
    }

    return Service.START_STICKY;
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate fragment_place_map view
    View rootView = inflater.inflate(R.layout.fragment_place_map, container, false);

    // Set views
    txtPlaceName = (TextView) rootView.findViewById(R.id.txtPlaceName);
    txtPlaceAddress = (TextView) rootView.findViewById(R.id.txtPlaceAddress);
    txtPlacePhone = (TextView) rootView.findViewById(R.id.txtPlacePhone);
    txtPlaceWeb = (TextView) rootView.findViewById(R.id.txtPlaceWeb);
    btnWaze = (Button) rootView.findViewById(R.id.btnWaze);

    // Get Intent and get place data from intent
    intent = getActivity().getIntent();
    double lat = intent.getDoubleExtra("lat", -1);
    double lon = intent.getDoubleExtra("lon", -1);
    String name = intent.getStringExtra("name");
    String web = intent.getStringExtra("web");
    String phone = intent.getStringExtra("phone");
    String address = intent.getStringExtra("address");
    place = new Place(name, address, lat, lon, web, phone);

    return rootView;
  }
Beispiel #13
0
 @Test
 public void testDoubleExtra() throws Exception {
   Intent intent = new Intent();
   assertSame(intent, intent.putExtra("foo", 2d));
   assertEquals(2d, intent.getExtras().get("foo"));
   assertEquals(2d, intent.getDoubleExtra("foo", -1));
 }
Beispiel #14
0
  /** center the map on the markers */
  public void centerMapFile() {
    MarkerOverlay mo = mapView.getMarkerOverlay();
    MapPosition mp = mapView.getMapViewPosition().getMapPosition();

    Intent intent = getIntent();
    if (intent.hasExtra(PARAMETERS.LAT)
        && intent.hasExtra(PARAMETERS.LON)
        && intent.hasExtra(PARAMETERS.ZOOM_LEVEL)) {
      double lat = intent.getDoubleExtra(PARAMETERS.LAT, 43.68411);
      double lon = intent.getDoubleExtra(PARAMETERS.LON, 10.84899);
      byte zoom_level = intent.getByteExtra(PARAMETERS.ZOOM_LEVEL, (byte) 13);
      byte zoom_level_min = intent.getByteExtra(PARAMETERS.ZOOM_LEVEL_MIN, (byte) 0);
      byte zoom_level_max = intent.getByteExtra(PARAMETERS.ZOOM_LEVEL_MAX, (byte) 30);
      /*ArrayList<MarkerDTO> list_marker = intent.getParcelableArrayListExtra(PARAMETERS.MARKERS);
      MarkerDTO mark = list_marker.get(0);*/
      mp = new MapPosition(new GeoPoint(lat, lon), zoom_level);
      mapView.getMapViewPosition().setMapPosition(mp);
      mapView.getMapZoomControls().setZoomLevelMin(zoom_level_min);
      mapView.getMapZoomControls().setZoomLevelMax(zoom_level_max);
    } else {
      if (mo != null) {
        // support only one marker
        MapPosition newMp = MarkerUtils.getMarkerCenterZoom(mo.getMarkers(), mp);
        if (newMp != null) {
          mapView.getMapViewPosition().setMapPosition(newMp);
        }
      }
    }
  }
    @Override
    public void onReceive(Context arg0, Intent arg1) {
      // TODO Auto-generated method stub
      long id = arg1.getLongExtra("id", 0);
      for (int i = 0; i < fileList.size(); i++) {
        TransferredFile mTransferredFile = fileList.get(i);
        if (mTransferredFile.getId() == id) {
          if (arg1.getAction() == Common.ACTION_REFRESH) {
            System.out.println("接收到刷新广播" + id);

            mTransferredFile.setLength(arg1.getLongExtra("length", 0));
            mTransferredFile.setStart(arg1.getBooleanExtra("isstart", false));
            mTransferredFile.setStarting(arg1.getBooleanExtra("isstarting", false));
            mTransferredFile.setSpeed(arg1.getDoubleExtra("speed", 0));
            fileList.set(i, mTransferredFile);
            break;

          } else if (arg1.getAction() == Common.ACTION_REMOVELOAD) {
            System.out.println("接收到传输中断广播");
            handler.sendEmptyMessage(0);
          } else if (arg1.getAction() == Common.ACTION_COMPLETED) {
            System.out.println("接收到传输完成广播");
            fileList.remove(i);
            loadingNum.setText("正在上传(" + fileList.size() + ")");
            doneFileList.addFirst(mTransferredFile);
            loadedNum.setText("已上传(" + doneFileList.size() + ")");
            loadedAdapter.notifyDataSetChanged();
            break;
          }
        }
      }
      handler.sendEmptyMessage(0);
    }
Beispiel #16
0
  @Override
  protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_street_view);

    Intent intent = getIntent();
    double lat = intent.getDoubleExtra("Lat", 0.0);
    double lon = intent.getDoubleExtra("Lon", 0.0);
    location = new LatLng(lat, lon);

    mStreetNameCheckbox = (CheckBox) findViewById(R.id.streetnames);
    mNavigationCheckbox = (CheckBox) findViewById(R.id.navigation);

    SupportStreetViewPanoramaFragment streetViewPanoramaFragment =
        (SupportStreetViewPanoramaFragment)
            getSupportFragmentManager().findFragmentById(R.id.streetviewpanorama);
    streetViewPanoramaFragment.getStreetViewPanoramaAsync(
        new OnStreetViewPanoramaReadyCallback() {
          @Override
          public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
            mStreetViewPanorama = panorama;
            mStreetViewPanorama.setStreetNamesEnabled(mStreetNameCheckbox.isChecked());
            mStreetViewPanorama.setUserNavigationEnabled(mNavigationCheckbox.isChecked());
            mStreetViewPanorama.setZoomGesturesEnabled(true);
            mStreetViewPanorama.setPanningGesturesEnabled(true);

            // Only set the panorama to SAN_FRAN on startup (when no panoramas have been
            // loaded which is when the savedInstanceState is null).
            if (savedInstanceState == null) {
              mStreetViewPanorama.setPosition(location);
            }
          }
        });
  }
  @Override
  protected void onResume() {
    super.onResume();
    Intent intent = getIntent();
    LatLon startPoint = null;
    if (intent != null) {
      double lat = intent.getDoubleExtra(SEARCH_LAT, 0);
      double lon = intent.getDoubleExtra(SEARCH_LON, 0);
      if (lat != 0 || lon != 0) {
        startPoint = new LatLon(lat, lon);
      }
    }
    if (startPoint == null && getParent() instanceof SearchActivity) {
      startPoint = ((SearchActivity) getParent()).getSearchPoint();
    }
    if (startPoint == null) {
      startPoint = settings.getLastKnownMapLocation();
    }

    LatLon pointToNavigate = settings.getPointToNavigate();
    if (!Algoritms.objectEquals(pointToNavigate, this.destinationLocation)
        || !Algoritms.objectEquals(startPoint, this.lastKnownMapLocation)) {
      destinationLocation = pointToNavigate;
      selectedDestinationLocation = destinationLocation;
      lastKnownMapLocation = startPoint;
      searchTransport();
    }
  }
Beispiel #18
0
 @Override
 public void onReceive(final Context context, final Intent intent) {
   if (intent != null && intent.hasExtra(BroadcastUtil.ACTION_PROGRESS_INFO)) {
     double progress = intent.getDoubleExtra(BroadcastUtil.ACTION_PROGRESS_INFO, 0);
     LogUtil.d("progress", "BlockchainBroadcastReceiver" + progress);
     pbSync.setProgress(progress);
   }
 }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (resultCode == RESULT_OK) {
     Double resultOfFactorialOperation = Double.valueOf(data.getDoubleExtra(FACTORIAL, 0));
     TextView outputTextView = (TextView) findViewById(R.id.textViewOutput);
     outputTextView.setText(resultOfFactorialOperation.toString());
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_manual_location);

    mLocationClient = new LocationClient(this, this, this);
    mActionBar = getSupportActionBar();
    mActionBar.setLogo(R.drawable.logo_navbar);
    mActionBar.setTitle("Location");
    mActionBar.setDisplayHomeAsUpEnabled(true);

    mPin = Constants.PIN;
    mArea = Constants.AREA;

    mParentLayout = (LinearLayout) findViewById(R.id.map_parent_layout);
    mDoneButton = (Button) findViewById(R.id.done_button);
    mCancelButton = (Button) findViewById(R.id.cancel_button);

    Intent intent = getIntent();
    Double default_lat = intent.getDoubleExtra("latitude", 0);
    Double default_lng = intent.getDoubleExtra("longitude", 0);
    if (default_lat > 0 && default_lng > 0) mSelectedLatLng = new LatLng(default_lat, default_lng);
    mDoneButton.setOnClickListener(this);
    mCancelButton.setOnClickListener(this);

    LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    Criteria criteria = new Criteria();

    // mLastlocation = mLocationClient.getLastLocation();
    // Loading map
    initilizeMap();
    /* try {


          boolean isNetworkConnected = NetworkChecker.isConnected(this);
    if(!isNetworkConnected){
    }else{
    	new FindBoundaries().execute();
    }

      } catch (Exception e) {
          e.printStackTrace();
      }*/

  }
 protected void quitActivity(Class<? extends Activity> next) {
   finish();
   if (next != null) {
     Intent intent = new Intent(this, next);
     if (getIntent() != null) {
       Intent cintent = getIntent();
       if (cintent.hasExtra(SearchActivity.SEARCH_LAT)
           && cintent.hasExtra(SearchActivity.SEARCH_LON)) {
         intent.putExtra(
             SearchActivity.SEARCH_LAT, cintent.getDoubleExtra(SearchActivity.SEARCH_LAT, 0));
         intent.putExtra(
             SearchActivity.SEARCH_LON, cintent.getDoubleExtra(SearchActivity.SEARCH_LON, 0));
       }
     }
     intent.putExtra(SELECT_ADDRESS, selectAddress);
     startActivity(intent);
   }
 }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
   super.onActivityResult(requestCode, resultCode, intent);
   if (resultCode == RESULT_OK) {
     switch (requestCode) {
       case LOCATION_REQUEST:
         final double latitude = intent.getDoubleExtra(LocationActivity.LATITUDE, 0);
         final double longitude = intent.getDoubleExtra(LocationActivity.LONGITUDE, 0);
         final String address = intent.getStringExtra(LocationActivity.ADDRESS);
         if (!TextUtils.isEmpty(address)) {
           messageAgent.sendLocation(latitude, longitude, address);
         } else {
           toast(R.string.chat_cannotGetYourAddressInfo);
         }
         hideBottomLayout();
         break;
     }
   }
 }
Beispiel #23
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "[ACTIVITY] onCreate");
    super.onCreate(savedInstanceState);
    instance = this;
    // 在使用SDK各组件之前初始化context信息,传入ApplicationContext
    // 注意该方法要再setContentView方法之前实现
    SDKInitializer.initialize(getApplicationContext());
    mStepValue = 0;
    mPaceValue = 0;

    setContentView(R.layout.layoutmain);

    mUtils = Utils.getInstance();
    mMapView = (MapView) findViewById(R.id.bmapView);
    // sendButton = (Button) findViewById(R.id.btn_location_send);
    Intent intent = getIntent();
    double latitude = intent.getDoubleExtra("latitude", 0);
    mCurrentMode = LocationMode.NORMAL;
    mBaiduMap = mMapView.getMap();
    MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(15.0f);
    mBaiduMap.setMapStatus(msu);
    initMapView();
    if (latitude == 0) {
      mMapView = new MapView(this, new BaiduMapOptions());
      mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration(mCurrentMode, true, null));
      showMapWithLocationClient();
    } else {
      double longtitude = intent.getDoubleExtra("longitude", 0);
      String address = intent.getStringExtra("address");
      LatLng p = new LatLng(latitude, longtitude);
      mMapView =
          new MapView(
              this, new BaiduMapOptions().mapStatus(new MapStatus.Builder().target(p).build()));
      showMap(latitude, longtitude, address);
    }
    // 注册 SDK 广播监听者
    IntentFilter iFilter = new IntentFilter();
    iFilter.addAction(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_ERROR);
    iFilter.addAction(SDKInitializer.SDK_BROADCAST_ACTION_STRING_NETWORK_ERROR);
    mBaiduReceiver = new BaiduSDKReceiver();
    registerReceiver(mBaiduReceiver, iFilter);
  }
  /* (non-Javadoc)
   * @see android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent)
   */
  @Override
  public void onReceive(Context context, Intent intent) {
    lat = intent.getDoubleExtra(IParkingConstants.LAT, 0.0);
    lng = intent.getDoubleExtra(IParkingConstants.LNG, 0.0);
    String s = "received notice! " + lat + ", " + lng;
    Log.i(TAG, s);

    address = intent.getStringExtra(IParkingConstants.ADDRESS);
    this.sendNotification(context, intent);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.exchange);
    Intent i = getIntent();
    country = i.getStringExtra("fCountry");
    currency = i.getStringExtra("fCurr");
    rate = i.getDoubleExtra("fRate", 1);
    amount = i.getIntExtra("fAmount", 1);

    ((TextView) findViewById(R.id.foreignCountry)).setText(country);
    ((TextView) findViewById(R.id.foreignCurrency)).setText(currency);
    ((TextView) findViewById(R.id.foreignRate)).setText(String.valueOf(rate));
    ((ImageView) findViewById(R.id.foreignFlag)).setBackgroundResource(Flags.get(currency));
    czkAmount = (EditText) findViewById(R.id.czkInput);
    forAmount = (EditText) findViewById(R.id.foreignInput);
    czkAmount.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}

          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            if (!czkAmount.hasFocus()) return;
            try {
              forAmount.setText(
                  String.valueOf(Double.valueOf(charSequence.toString()) / rate * amount));
            } catch (Exception e) {
              e.printStackTrace();
            }
          }

          @Override
          public void afterTextChanged(Editable editable) {}
        });
    forAmount.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}

          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            if (!forAmount.hasFocus()) return;
            try {
              czkAmount.setText(
                  String.valueOf(Double.valueOf(charSequence.toString()) * rate / amount));
            } catch (Exception e) {
              e.printStackTrace();
            }
          }

          @Override
          public void afterTextChanged(Editable editable) {}
        });
  }
Beispiel #26
0
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (resultCode == Activity.RESULT_OK) {
     switch (requestCode) {
       case UnicyclistActivity.GET_PHOTO:
         imageUri = data.getData();
         getContentResolver().notifyChange(imageUri, null);
         ContentResolver cr = getContentResolver();
         try {
           Bitmap bitmap = android.provider.MediaStore.Images.Media.getBitmap(cr, imageUri);
           cameraButton.setImageBitmap(bitmap);
         } catch (Exception e) {
           Log.e("Camera", e.toString());
         }
         break;
       case UnicyclistActivity.SELECT_LOCATION:
         latitude = data.getDoubleExtra("latitude", 0);
         longitude = data.getDoubleExtra("longitude", 0);
         break;
     }
   }
 }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    EventService service =
        new EventServiceImpl(
            getString(R.string.thing_broker_server),
            getString(R.string.thing_broker_port),
            null,
            false);
    Event event = new Event();
    event.setThingId(getString(R.string.thing_broker_thing_name));
    Map<String, String> gameInfo = new HashMap<String, String>();

    if (resultCode == RESULT_OK) {
      if (data.getStringExtra("method").equals("nfc")) {
        nfc_upload = data.getStringExtra("uploadResult");
        System.out.println("NFC upload result: " + nfc_upload);
        if (nfc_upload != null && !nfc_upload.equals("")) {
          webView.loadUrl("javascript:gotNFC('" + nfc_upload + "');");
        }

      } else if (data.getStringExtra("method").equals("qr")) {
        System.out.println("QR value");
        qr_upload = data.getStringExtra("qr_result");
        player = data.getStringExtra("playernumber");
        if (qr_upload != null && !qr_upload.equals("")) {
          webView.loadUrl("javascript:gotQR('" + qr_upload + "');");

          gameInfo.put("type", "qrResult");
          gameInfo.put("player", player);
          gameInfo.put("value", qr_upload);
          event.setInfo(gameInfo);
          service.postEvent(STANDARD_MESSAGE, (ThingBrokerRequestListener) this, event, true);
        }

      } else if (data.getStringExtra("method").equals("accel")) {
        System.out.println("ACCEL");
        accelerometer_rate = data.getDoubleExtra("accel_rate", 5.0);
        accelerometer_enabled = true;
        player = data.getStringExtra("playernumber");
        startAccelUpload();
        System.out.println("start accel Upload");
      } else if (data.getStringExtra("method").equals("upload")) {
        System.out.println("Upload this shit now");
        uploadDimensionsTest = data.getStringExtra("uploadResult");
        System.out.println("Upload Dimension Test" + uploadDimensionsTest);
        if (uploadDimensionsTest != null && !uploadDimensionsTest.equals("")) {
          webView.loadUrl("javascript:gotImage('" + uploadDimensionsTest + "');");
        }
        System.out.println("uploadDimesnions passed over");
      }
    }
  }
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {
      switch (requestCode) {
        case BmobConstants.REQUESTCODE_TAKE_CAMERA: // 当取到值的时候才上传path路径下的图片到服务器
          Log.i("yuyang", "本地图片的地址:" + localCameraPath);
          sendImageMessage(localCameraPath);
          break;
        case BmobConstants.REQUESTCODE_TAKE_LOCAL:
          if (data != null) {
            Uri selectedImage = data.getData();
            if (selectedImage != null) {
              Cursor cursor = getContentResolver().query(selectedImage, null, null, null, null);
              cursor.moveToFirst();
              int columnIndex = cursor.getColumnIndex("_data");
              String localSelectPath = cursor.getString(columnIndex);
              cursor.close();
              if (localSelectPath == null || localSelectPath.equals("null")) {
                ShowToast("找不到您想要的图片");
                return;
              }
              sendImageMessage(localSelectPath);
            }
          }
          break;
        case BmobConstants.REQUESTCODE_TAKE_LOCATION: // 地理位置
          double latitude = data.getDoubleExtra("x", 0); // 维度
          double longtitude = data.getDoubleExtra("y", 0); // 经度
          String address = data.getStringExtra("address");
          if (address != null && !address.equals("")) {
            sendLocationMessage(address, latitude, longtitude);
          } else {
            ShowToast("无法获取到您的位置信息!");
          }

          break;
      }
    }
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 1) {
      if (resultCode == Activity.RESULT_OK) {
        String city = data.getStringExtra("city");
        lat_location = data.getDoubleExtra("lat", 0.0);
        longi_location = data.getDoubleExtra("long", 0.0);

        String s_lat = new DecimalFormat("#.##").format(lat_location);
        String s_longi = new DecimalFormat("#.##").format(longi_location);

        txtLocation.setText(city + "   latLng: " + s_lat + " / " + s_longi);
      }
      if (resultCode == Activity.RESULT_CANCELED) {
        // Write your code if there's no result
      }
    }
    if (requestCode == 2) {
      if (resultCode == Activity.RESULT_OK) {
        String city = data.getStringExtra("city");
        lat_pickup = data.getDoubleExtra("lat", 0.0);
        longi_pickup = data.getDoubleExtra("long", 0.0);

        String s_lat = new DecimalFormat("#.##").format(lat_pickup);
        String s_longi = new DecimalFormat("#.##").format(longi_pickup);

        txtPickUp.setText(city + "   latLng: " + s_lat + " / " + s_longi);
      }
      if (resultCode == Activity.RESULT_CANCELED) {
        // Write your code if there's no result
      }
    }
    if (requestCode == 3) {
      if (resultCode == Activity.RESULT_OK) {

        invited_friends = data.getStringExtra("invited_friends");
      }
    }
  }
Beispiel #30
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.add_segment_layout);

    parentLayout = (RelativeLayout) findViewById(R.id.parentLayout);
    name = (EditText) findViewById(R.id.segment_name);
    distance = (EditText) findViewById(R.id.segment_distance);
    cost = (EditText) findViewById(R.id.segment_cost);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("Segments");
    setSupportActionBar(toolbar);

    sharedPreferences = this.getSharedPreferences("MY_PREFS", Context.MODE_PRIVATE);

    ok = (Button) findViewById(R.id.ok);
    cancel = (Button) findViewById(R.id.cancel);

    editSegment = getIntent();

    if (editSegment.getStringExtra("name") != null) {

      ok.setText(R.string.edit);

      name.setText("" + editSegment.getStringExtra("name"));
      distance.setText("" + editSegment.getDoubleExtra("distance", 0.0));
      cost.setText("" + editSegment.getDoubleExtra("cost", 0.0));
      segment_id = editSegment.getStringExtra("id");

    } else {
      ok.setText(R.string.add);
    }

    current_segments = editSegment.getStringArrayListExtra("current_segments");

    ok.setOnClickListener(this);
    cancel.setOnClickListener(this);
  }