List of usage examples for android.location LocationManager NETWORK_PROVIDER
String NETWORK_PROVIDER
To view the source code for android.location LocationManager NETWORK_PROVIDER.
Click Source Link
From source file:org.cowboycoders.cyclisimo.turbo.TurboService.java
private void enableMockLocations() { enableLocationProvider(MOCK_LOCATION_PROVIDER); // enable any alternatives otherwise : could provide a last known location networkProviderEnabled = enableLocationProvider(LocationManager.NETWORK_PROVIDER); }
From source file:org.cowboycoders.cyclisimo.turbo.TurboService.java
private void disableMockLocations() { disableLocationProvider(MOCK_LOCATION_PROVIDER); if (networkProviderEnabled) disableLocationProvider(LocationManager.NETWORK_PROVIDER); }
From source file:com.ibm.mf.geofence.demo.MapsActivity.java
void initGeofences() { try {/* w w w . ja v a 2s. c o m*/ final List<MFGeofence> fences = DemoUtils.getAllGeofencesFromDB(); log.debug("initGeofences() " + (fences == null ? 0 : fences.size()) + " fences in local DB"); geofenceHolder.clearFences(); geofenceHolder.addFences(fences); runOnUiThread(new Runnable() { @Override public void run() { try { for (MFGeofence g : fences) { boolean active = false; if (currentLocation != null) { Location loc = new Location(LocationManager.NETWORK_PROVIDER); loc.setLatitude(g.getLatitude()); loc.setLongitude(g.getLongitude()); loc.setTime(System.currentTimeMillis()); active = loc.distanceTo(currentLocation) <= g.getRadius(); } refreshGeofenceInfo(g, active); } } catch (Exception e) { log.error(e.getMessage(), e); } } }); } catch (Exception e) { log.error(e.getMessage(), e); } }
From source file:net.jongrakko.zipsuri.fragment.ExpertModifyFragment.java
@Override public boolean onMyLocationButtonClick() { LocationManager mLocationManager = (LocationManager) getContext() .getSystemService(Context.LOCATION_SERVICE); if (!mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { ProgressManger.showToast(" ."); } else {/*w w w. j ava2s . c om*/ ProgressManger.showToast(" ..."); } return false; }
From source file:net.e_fas.oss.tabijiman.MapsActivity.java
@Override public void onMapReady(GoogleMap googleMap) { e_print("onMapReady"); mMap = googleMap;//from w w w .ja v a 2 s.c om GoFukuiButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CameraPosition cameraPos = new CameraPosition.Builder().target(new LatLng(36.0642988, 136.220012)) .zoom(10.0f).bearing(0).build(); mMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPos)); GoFukuiButton.setVisibility(View.GONE); } }); CameraPosition cameraPos = new CameraPosition.Builder().target(new LatLng(36.0614444, 136.2229937)) .zoom(zoomLevel).bearing(0).build(); mMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPos)); // ?? mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { Toast.makeText(getApplicationContext(), marker.getTitle(), Toast.LENGTH_LONG).show(); return false; } }); mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { @Override public View getInfoWindow(Marker marker) { return null; } @Override public View getInfoContents(Marker marker) { View view = getLayoutInflater().inflate(R.layout.info_window, null); // TextView title = (TextView) view.findViewById(R.id.info_title); title.setText(marker.getTitle()); e_print("marker_Snippet >> " + marker.getSnippet()); if (marker.getSnippet() == null) { view.findViewById(R.id.info_address).setVisibility(View.GONE); } else { TextView address = (TextView) view.findViewById(R.id.info_address); address.setText(marker.getSnippet()); } return view; } }); mMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { e_print("title_name >> " + marker.getTitle()); //DB()?? SQLiteDatabase dbRead = helper.getReadableDatabase(); //SQL String select_frame_sql = "SELECT * FROM frame WHERE `name` = ? AND `lat` = ? AND `lng` = ?"; String select_place_sql = "SELECT * FROM place WHERE `name` = ? AND `lat` = ? AND `lng` = ?"; //SQL? Cursor cursor = dbRead.rawQuery(select_place_sql, new String[] { marker.getTitle(), String.valueOf(marker.getPosition().latitude), String.valueOf(marker.getPosition().longitude) }); e_print("cursor_count >> " + cursor.getCount()); if (cursor.getCount() != 0) { cursor.moveToFirst(); e_print("lat >> " + marker.getPosition().latitude + " lng >> " + marker.getPosition().longitude); Intent MoreInfo = new Intent(getApplicationContext(), MoreInfo.class); MoreInfo.putExtra("id", cursor.getInt(cursor.getColumnIndex("_id"))); MoreInfo.putExtra("cat", "place"); cursor.close(); startActivity(MoreInfo); } else { cursor.close(); //SQL? Cursor cursor2 = dbRead.rawQuery(select_frame_sql, new String[] { marker.getTitle(), String.valueOf(marker.getPosition().latitude), String.valueOf(marker.getPosition().longitude) }); cursor2.moveToFirst(); /* * distance[0] = [??] * distance[1] = [???] * distance[2] = [???] */ float[] distance = getDistance(nowLocation.latitude, nowLocation.longitude, marker.getPosition().latitude, marker.getPosition().longitude); Intent MoreInfo = new Intent(getApplicationContext(), MoreInfo.class); MoreInfo.putExtra("dist", distance[0]); MoreInfo.putExtra("id", cursor2.getInt(cursor2.getColumnIndex("_id"))); MoreInfo.putExtra("cat", "frame"); cursor2.close(); startActivity(MoreInfo); } } }); mMap.setOnMyLocationButtonClickListener(new GoogleMap.OnMyLocationButtonClickListener() { @Override public boolean onMyLocationButtonClick() { Location location = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); e_print("MyLocation >> " + location); Toast.makeText(getApplicationContext(), "location >> " + location, Toast.LENGTH_SHORT).show(); return false; } }); mMap.setMyLocationEnabled(true); // MyLocationButton? UiSettings settings = mMap.getUiSettings(); settings.setMyLocationButtonEnabled(true); //?? View locationButton = ((View) super.findViewById(Integer.parseInt("1")).getParent()) .findViewById(Integer.parseInt("2")); RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) locationButton.getLayoutParams(); rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); rlp.setMargins(0, 0, 180, 180); print("mMap >> insert"); for (String provider : providers) { e_print("enable_providers >> " + provider); mLocationManager.requestLocationUpdates(provider, 3000, 0, this); } if (mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { e_print("Provider_enable >> NETWORK"); mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10000, 0, this); } else if (mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { e_print("Providers_enable >> GPS"); mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 0, this); } else { e_print("All_Providers_Disable"); } }
From source file:com.zainsoft.ramzantimetable.QiblaActivity.java
private void registerForGPS() { Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_COARSE); criteria.setPowerRequirement(Criteria.POWER_LOW); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false);/*ww w. j av a 2 s . c o m*/ criteria.setSpeedRequired(false); criteria.setCostAllowed(true); LocationManager locationManager = ((LocationManager) getSystemService(Context.LOCATION_SERVICE)); String provider = locationManager.getBestProvider(criteria, true); if (provider != null) { locationManager.requestLocationUpdates(provider, MIN_LOCATION_TIME, MIN_LOCATION_DISTANCE, qiblaManager); } locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_LOCATION_TIME, MIN_LOCATION_DISTANCE, qiblaManager); locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, MIN_LOCATION_TIME, MIN_LOCATION_DISTANCE, qiblaManager); Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (location == null) { location = ((LocationManager) getSystemService(Context.LOCATION_SERVICE)) .getLastKnownLocation(LocationManager.GPS_PROVIDER); } if (location != null) { qiblaManager.onLocationChanged(location); } }
From source file:de.uni.stuttgart.informatik.ToureNPlaner.UI.Activities.MapScreen.MapScreen.java
@Override protected void onResume() { super.onResume(); //-----get mapScreen_Preferences SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); instantRequest = MapScreenPreferences.Instant .valueOf(preferences.getString("instant_request", MapScreenPreferences.Instant.ALWAYS.name())); this.supportInvalidateOptionsMenu(); setupMapView(preferences);// w w w . j a v a 2 s . c o m // 1 minutes, 10 meters try { locManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1 * 60 * 1000, 10, gpsListener); } catch (IllegalArgumentException e) { // happens on emulator } }
From source file:com.davidmascharka.lips.MainActivity.java
private void updateScanResults() { if (userInitiatedScan) { //Toast.makeText(this, "Scan finished", Toast.LENGTH_SHORT).show(); resetWifiReadings(building);/*from w w w. j a v a 2 s .co m*/ scanResults = wifiManager.getScanResults(); for (ScanResult result : scanResults) { if (wifiReadings.get(result.BSSID) != null) { wifiReadings.put(result.BSSID, result.level); } else { // BSSID wasn't programmed in - notify user //Toast.makeText(this, "This BSSID is new: " + result.BSSID, // Toast.LENGTH_SHORT).show(); } } // Get a filehandle for /sdcard/indoor_localization/dataset_BUILDING.txt File root = Environment.getExternalStorageDirectory(); File dir = new File(root.getAbsolutePath() + "/indoor_localization"); dir.mkdirs(); File file = new File(dir, "dataset_" + building + ".txt"); try { FileOutputStream outputStream = new FileOutputStream(file, true); PrintWriter writer = new PrintWriter(outputStream); writer.print(accelerometerX + "," + accelerometerY + "," + accelerometerZ + "," + magneticX + "," + magneticY + "," + magneticZ + "," + light + "," + rotationX + "," + rotationY + "," + rotationZ + "," + orientation[0] + "," + orientation[1] + "," + orientation[2]); for (String key : wifiReadings.keySet()) { writer.print("," + wifiReadings.get(key)); } if (location != null) { writer.print("," + location.getLatitude() + "," + location.getLongitude() + "," + location.getAccuracy()); } else { //@author Mahesh Gaya added permission if-statment if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_WIFI_STATE) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(this, android.Manifest.permission.CHANGE_WIFI_STATE) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { Log.i(TAG, "Permissions have NOT been granted. Requesting permissions."); requestMyPermissions(); } else { Log.i(TAG, "Permissions have already been granted. Getting last known location from GPS"); location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); } if (location != null) { writer.print("," + location.getLatitude() + "," + location.getLongitude() + "," + location.getAccuracy()); } else { //@author Mahesh Gaya added permission if-statment if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_WIFI_STATE) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(this, android.Manifest.permission.CHANGE_WIFI_STATE) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { Log.i(TAG, "Permissions have NOT been granted. Requesting permissions."); requestMyPermissions(); } else { Log.i(TAG, "Permssions have already been granted. Getting last know location from network"); location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); } if (location != null) { writer.print("," + location.getLatitude() + "," + location.getLongitude() + "," + location.getAccuracy()); } else { Toast.makeText(this, "Location was null", Toast.LENGTH_SHORT).show(); writer.print(",?,?,?"); } } } TextView xposition = (TextView) findViewById(R.id.text_xposition); TextView yposition = (TextView) findViewById(R.id.text_yposition); writer.print("," + xposition.getText().toString().substring(3)); writer.print("," + yposition.getText().toString().substring(3)); writer.print(" %" + (new Timestamp(System.currentTimeMillis())).toString()); writer.print("\n\n"); writer.flush(); writer.close(); Toast.makeText(this, "Done saving datapoint", Toast.LENGTH_SHORT).show(); userInitiatedScan = false; } catch (Exception e) { Toast.makeText(this, "There was an error", Toast.LENGTH_SHORT).show(); Log.e("ERROR", Log.getStackTraceString(e)); } } Button button = (Button) findViewById(R.id.button_confirm); button.setClickable(true); }
From source file:org.borderstone.tagtags.TTProtocolActivity.java
private void startLocationListener() { locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); try {/*from w w w. j a va2 s . c o m*/ gps_enabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); } catch (Exception ignored) { } try { network_enabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); } catch (Exception ignored) { } if (!gps_enabled && !network_enabled) { Toast.makeText(this, "Location services are not active!", Toast.LENGTH_LONG).show(); } else { if (network_enabled) provider = LocationManager.NETWORK_PROVIDER; if (gps_enabled) provider = LocationManager.GPS_PROVIDER; if (checkPermission()) locationManager.requestLocationUpdates(provider, 0, 0, this); tick(); setGPSButtonEnabled(true); Toast.makeText(this, "Press the button again to save the coordinates!", Toast.LENGTH_LONG).show(); } }
From source file:it.sasabz.android.sasabus.fragments.OnlineSearchFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { this.inflater_glob = inflater; result = inflater.inflate(R.layout.online_search_layout, container, false); Date datum = new Date(); SimpleDateFormat simple = new SimpleDateFormat("dd.MM.yyyy HH:mm"); TextView datetime = (TextView) result.findViewById(R.id.time); String datetimestring = ""; datetimestring = simple.format(datum); datetime.setText(datetimestring);/*w w w .j av a2s . c o m*/ Button search = (Button) result.findViewById(R.id.search); search.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AutoCompleteTextView from = (AutoCompleteTextView) result.findViewById(R.id.from_text); AutoCompleteTextView to = (AutoCompleteTextView) result.findViewById(R.id.to_text); TextView datetime = (TextView) result.findViewById(R.id.time); String from_txt = getThis().getResources().getString(R.string.from_txt); if ((!from.getText().toString().trim().equals("") || !from.getHint().toString().trim().equals(from_txt)) && !to.getText().toString().trim().equals("")) { //Intent getSelect = new Intent(getThis().getActivity(), OnlineSelectStopActivity.class); String fromtext = ""; if (from.getText().toString().trim().equals("")) fromtext = from.getHint().toString(); else fromtext = from.getText().toString(); String totext = to.getText().toString(); fromtext = "(" + fromtext.replace(" -", ")"); totext = "(" + totext.replace(" -", ")"); Fragment fragment = new OnlineSelectFragment(fromtext, totext, datetime.getText().toString()); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); Fragment old = fragmentManager.findFragmentById(R.id.onlinefragment); if (old != null) { ft.remove(old); } ft.add(R.id.onlinefragment, fragment); ft.addToBackStack(null); ft.commit(); fragmentManager.executePendingTransactions(); } } }); datetime.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Create the dialog final Dialog mDateTimeDialog = new Dialog(getThis().getActivity()); // Inflate the root layout final RelativeLayout mDateTimeDialogView = (RelativeLayout) inflater_glob .inflate(R.layout.date_time_dialog, null); // Grab widget instance final DateTimePicker mDateTimePicker = (DateTimePicker) mDateTimeDialogView .findViewById(R.id.DateTimePicker); TextView dt = (TextView) result.findViewById(R.id.time); String datetimestring = dt.getText().toString(); SimpleDateFormat datetimeformat = new SimpleDateFormat("dd.MM.yyyy HH:mm"); Date datetime = null; try { datetime = datetimeformat.parse(datetimestring); } catch (Exception e) { ; } mDateTimePicker.updateTime(datetime.getHours(), datetime.getMinutes()); mDateTimePicker.updateDate(datetime.getYear() + 1900, datetime.getMonth(), datetime.getDate()); // Check is system is set to use 24h time (this doesn't seem to // work as expected though) final String timeS = android.provider.Settings.System.getString( getThis().getActivity().getContentResolver(), android.provider.Settings.System.TIME_12_24); final boolean is24h = !(timeS == null || timeS.equals("12")); ((Button) mDateTimeDialogView.findViewById(R.id.SetDateTime)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mDateTimePicker.clearFocus(); String datetimestring = ""; int day = mDateTimePicker.get(Calendar.DAY_OF_MONTH); int month = mDateTimePicker.get(Calendar.MONTH) + 1; int year = mDateTimePicker.get(Calendar.YEAR); int hour = 0; int min = 0; int append = 0; if (mDateTimePicker.is24HourView()) { hour = mDateTimePicker.get(Calendar.HOUR_OF_DAY); min = mDateTimePicker.get(Calendar.MINUTE); } else { hour = mDateTimePicker.get(Calendar.HOUR); min = mDateTimePicker.get(Calendar.MINUTE); if (mDateTimePicker.get(Calendar.AM_PM) == Calendar.AM) { append = 1; } else { append = 2; } } if (day < 10) { datetimestring += "0"; } datetimestring += (day + "."); if (month < 10) { datetimestring += "0"; } datetimestring += (month + "." + year + " "); if (hour < 10) { datetimestring += "0"; } datetimestring += (hour + ":"); if (min < 10) { datetimestring += "0"; } datetimestring += min; switch (append) { case 1: datetimestring += " AM"; break; case 2: datetimestring += " PM"; break; } TextView time = (TextView) result.findViewById(R.id.time); time.setText(datetimestring); mDateTimeDialog.dismiss(); } }); // Cancel the dialog when the "Cancel" button is clicked ((Button) mDateTimeDialogView.findViewById(R.id.CancelDialog)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimeDialog.cancel(); } }); // Reset Date and Time pickers when the "Reset" button is // clicked ((Button) mDateTimeDialogView.findViewById(R.id.ResetDateTime)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimePicker.reset(); } }); // Setup TimePicker mDateTimePicker.setIs24HourView(is24h); // No title on the dialog window mDateTimeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // Set the dialog content view mDateTimeDialog.setContentView(mDateTimeDialogView); // Display the dialog mDateTimeDialog.show(); } }); ImageButton datepicker = (ImageButton) result.findViewById(R.id.datepicker); datepicker.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Create the dialog final Dialog mDateTimeDialog = new Dialog(getThis().getActivity()); // Inflate the root layout final RelativeLayout mDateTimeDialogView = (RelativeLayout) inflater_glob .inflate(R.layout.date_time_dialog, null); // Grab widget instance final DateTimePicker mDateTimePicker = (DateTimePicker) mDateTimeDialogView .findViewById(R.id.DateTimePicker); TextView dt = (TextView) result.findViewById(R.id.time); String datetimestring = dt.getText().toString(); SimpleDateFormat datetimeformat = new SimpleDateFormat("dd.MM.yyyy HH:mm"); Date datetime = null; try { datetime = datetimeformat.parse(datetimestring); } catch (Exception e) { ; } mDateTimePicker.updateTime(datetime.getHours(), datetime.getMinutes()); mDateTimePicker.updateDate(datetime.getYear() + 1900, datetime.getMonth(), datetime.getDate()); // Check is system is set to use 24h time (this doesn't seem to // work as expected though) final String timeS = android.provider.Settings.System.getString( getThis().getActivity().getContentResolver(), android.provider.Settings.System.TIME_12_24); final boolean is24h = !(timeS == null || timeS.equals("12")); // Update demo TextViews when the "OK" button is clicked ((Button) mDateTimeDialogView.findViewById(R.id.SetDateTime)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mDateTimePicker.clearFocus(); String datetimestring = ""; int day = mDateTimePicker.get(Calendar.DAY_OF_MONTH); int month = mDateTimePicker.get(Calendar.MONTH) + 1; int year = mDateTimePicker.get(Calendar.YEAR); int hour = 0; int min = 0; int append = 0; if (mDateTimePicker.is24HourView()) { hour = mDateTimePicker.get(Calendar.HOUR_OF_DAY); min = mDateTimePicker.get(Calendar.MINUTE); } else { hour = mDateTimePicker.get(Calendar.HOUR); min = mDateTimePicker.get(Calendar.MINUTE); if (mDateTimePicker.get(Calendar.AM_PM) == Calendar.AM) { append = 1; } else { append = 2; } } if (day < 10) { datetimestring += "0"; } datetimestring += (day + "."); if (month < 10) { datetimestring += "0"; } datetimestring += (month + "." + year + " "); if (hour < 10) { datetimestring += "0"; } datetimestring += (hour + ":"); if (min < 10) { datetimestring += "0"; } datetimestring += min; switch (append) { case 1: datetimestring += " AM"; break; case 2: datetimestring += " PM"; break; } TextView time = (TextView) result.findViewById(R.id.time); time.setText(datetimestring); mDateTimeDialog.dismiss(); } }); // Cancel the dialog when the "Cancel" button is clicked ((Button) mDateTimeDialogView.findViewById(R.id.CancelDialog)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimeDialog.cancel(); } }); // Reset Date and Time pickers when the "Reset" button is // clicked ((Button) mDateTimeDialogView.findViewById(R.id.ResetDateTime)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimePicker.reset(); } }); // Setup TimePicker mDateTimePicker.setIs24HourView(is24h); // No title on the dialog window mDateTimeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // Set the dialog content view mDateTimeDialog.setContentView(mDateTimeDialogView); // Display the dialog mDateTimeDialog.show(); } }); from = (AutoCompleteTextView) result.findViewById(R.id.from_text); to = (AutoCompleteTextView) result.findViewById(R.id.to_text); from.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { InputMethodManager mgr = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(from.getWindowToken(), 0); } }); to.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { InputMethodManager mgr = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(to.getWindowToken(), 0); } }); LocationManager locman = (LocationManager) this.getActivity().getSystemService(Context.LOCATION_SERVICE); Location lastloc = locman.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (MySQLiteDBAdapter.exists(this.getActivity())) { if (lastloc == null) { lastloc = locman.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); } if (lastloc != null) { try { Palina palina = PalinaList.getPalinaGPS(lastloc); if (palina != null) { from.setHint(palina.toString()); } } catch (Exception e) { Log.e("HomeActivity", "Fehler bei der Location", e); } } else { Log.v("HomeActivity", "No location found!!"); } Vector<DBObject> palinalist = PalinaList.getNameList(); MyAutocompleteAdapter adapterfrom = new MyAutocompleteAdapter(this.getActivity(), android.R.layout.simple_list_item_1, palinalist); MyAutocompleteAdapter adapterto = new MyAutocompleteAdapter(this.getActivity(), android.R.layout.simple_list_item_1, palinalist); from.setAdapter(adapterfrom); to.setAdapter(adapterto); InputMethodManager mgr = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(from.getWindowToken(), 0); mgr.hideSoftInputFromWindow(to.getWindowToken(), 0); } Button favorites = (Button) result.findViewById(R.id.favorites); favorites.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { SelectFavoritenDialog dialog = new SelectFavoritenDialog(getThis()); dialog.show(); } }); Button mappicker = (Button) result.findViewById(R.id.map); mappicker.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), MapSelectActivity.class); startActivityForResult(intent, REQUESTCODE_ACTIVITY); } }); return result; }