List of usage examples for android.location LocationManager GPS_PROVIDER
String GPS_PROVIDER
To view the source code for android.location LocationManager GPS_PROVIDER.
Click Source Link
From source file:com.example.angelina.travelapp.places.PlacesActivity.java
private boolean locationTrackingEnabled() { final LocationManager locationManager = (LocationManager) getApplicationContext() .getSystemService(Context.LOCATION_SERVICE); return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); }
From source file:com.shadowmaps.example.GpsTestActivity.java
@Override protected void onResume() { super.onResume(); SharedPreferences settings = Application.getPrefs(); if (GpsTestUtil.isRotationVectorSensorSupported(this)) { // Use the modern rotation vector sensors Sensor vectorSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR); mSensorManager.registerListener(this, vectorSensor, 16000); // ~60hz } else {//from w ww . ja v a2 s . c om // Use the legacy orientation sensors Sensor sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION); if (sensor != null) { mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_GAME); } } if (!mService.isProviderEnabled(LocationManager.GPS_PROVIDER)) { promptEnableGps(); } /** * Check preferences to see how they should be initialized */ checkKeepScreenOn(settings); checkTimeAndDistance(settings); checkTrueNorth(settings); }
From source file:org.nasa.openspace.gc.geolocation.LocationActivity.java
@Override protected void onStart() { super.onStart(); // Check if the GPS setting is currently enabled on the device. // This verification should be done during onStart() because the system calls this method // when the user returns to the activity, which ensures the desired location provider is // enabled each time the activity resumes from the stopped state. LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); final boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); if (!gpsEnabled) { // Build an alert dialog here that requests that the user enable // the location services, then when the user clicks the "OK" button, // call enableLocationSettings() new EnableGpsDialogFragment().show(getSupportFragmentManager(), "enableGpsDialog"); }//from w w w .j av a 2 s .co m }
From source file:cl.gisred.android.RepartoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LicenseResult licenseResult = ArcGISRuntime.setClientId(CLIENT_ID); LicenseLevel licenseLevel = ArcGISRuntime.License.getLicenseLevel(); if (licenseResult == LicenseResult.VALID && licenseLevel == LicenseLevel.BASIC) { //Toast.makeText(getApplicationContext(), "Licencia bsica vlida", Toast.LENGTH_SHORT).show(); } else if (licenseResult == LicenseResult.VALID && licenseLevel == LicenseLevel.STANDARD) { //Toast.makeText(getApplicationContext(), "Licencia standard vlida", Toast.LENGTH_SHORT).show(); }//from w w w . j a v a2s .c o m setContentView(R.layout.activity_reparto); Toolbar toolbar = (Toolbar) findViewById(R.id.apptool); setSupportActionBar(toolbar); myMapView = (MapView) findViewById(R.id.map); myMapView.enableWrapAround(true); /*Get Credenciales String*/ Bundle bundle = getIntent().getExtras(); usuar = bundle.getString("usuario"); passw = bundle.getString("password"); modulo = bundle.getString("modulo"); empresa = bundle.getString("empresa"); //Crea un intervalo entre primer dia del mes y dia actual Calendar oCalendarStart = Calendar.getInstance(); oCalendarStart.set(Calendar.DAY_OF_MONTH, 1); oCalendarStart.set(Calendar.HOUR, 6); Calendar oCalendarEnd = Calendar.getInstance(); oCalendarEnd.set(Calendar.HOUR, 23); TimeExtent oTimeInterval = new TimeExtent(oCalendarStart, oCalendarEnd); //Set Credenciales setCredenciales(usuar, passw); if (Build.VERSION.SDK_INT >= 23) verifPermisos(); else startGPS(); setLayersURL(this.getResources().getString(R.string.url_Mapabase), "MAPABASE"); setLayersURL(this.getResources().getString(R.string.url_token), "TOKENSRV"); setLayersURL(this.getResources().getString(R.string.srv_Repartos), "SRV_REPARTO"); LyMapabase = new ArcGISDynamicMapServiceLayer(din_urlMapaBase, null, credenciales); LyMapabase.setVisible(true); LyReparto = new ArcGISFeatureLayer(srv_reparto, ArcGISFeatureLayer.MODE.ONDEMAND, credenciales); LyReparto.setDefinitionExpression(String.format("empresa = '%s'", empresa)); LyReparto.setTimeInterval(oTimeInterval); LyReparto.setMinScale(8000); LyReparto.setVisible(true); myMapView.addLayer(mRoadBaseMaps, 0); myMapView.addLayer(LyReparto, 1); sqlReparto = new RepartoSQLiteHelper(RepartoActivity.this, dbName, null, 2); txtContador = (TextView) findViewById(R.id.tvContador); txtContSesion = (TextView) findViewById(R.id.tvContadorSesion); txtListen = (EditText) findViewById(R.id.txtListen); txtListen.setEnabled(bGpsActive); if (!txtListen.hasFocus()) txtListen.requestFocus(); txtListen.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (s.toString().contains("\n") || s.toString().length() == RepartoClass.length_code) { guardarRegistro(s.toString().trim()); s.clear(); } } }); final FloatingActionButton btnGps = (FloatingActionButton) findViewById(R.id.action_gps); btnGps.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { myMapView.setExtent(ldm.getPoint()); myMapView.setScale(4000, true); } } }); myMapView.setOnStatusChangedListener(new OnStatusChangedListener() { @Override public void onStatusChanged(Object o, STATUS status) { if (ldm != null) { Point oPoint = ldm.getPoint(); myMapView.centerAndZoom(oPoint.getX(), oPoint.getY(), 0.003f); myMapView.zoomin(true); } if (status == STATUS.LAYER_LOADING_FAILED) { // Check if a layer is failed to be loaded due to security if ((status.getError()) instanceof EsriSecurityException) { EsriSecurityException securityEx = (EsriSecurityException) status.getError(); if (securityEx.getCode() == EsriSecurityException.AUTHENTICATION_FAILED) Toast.makeText(myMapView.getContext(), "Su cuenta tiene permisos limitados, contacte con el administrador para solicitar permisos faltantes", Toast.LENGTH_SHORT).show(); else if (securityEx.getCode() == EsriSecurityException.TOKEN_INVALID) Toast.makeText(myMapView.getContext(), "Token invlido! Vuelva a iniciar sesin!", Toast.LENGTH_SHORT).show(); else if (securityEx.getCode() == EsriSecurityException.TOKEN_SERVICE_NOT_FOUND) Toast.makeText(myMapView.getContext(), "Servicio token no encontrado! Reintente iniciar sesin!", Toast.LENGTH_SHORT) .show(); else if (securityEx.getCode() == EsriSecurityException.UNTRUSTED_SERVER_CERTIFICATE) Toast.makeText(myMapView.getContext(), "Untrusted Host! Resubmit!", Toast.LENGTH_SHORT) .show(); if (o instanceof ArcGISFeatureLayer) { // Set user credential through username and password UserCredentials creds = new UserCredentials(); creds.setUserAccount(usuar, passw); LyMapabase.reinitializeLayer(creds); } } } } }); readCountData(); updDashboard(); Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { @Override public void run() { if (iContRep > 0) { Toast.makeText(getApplicationContext(), "Sincronizando datos...", Toast.LENGTH_SHORT) .show(); readData(); enviarDatos(); } } }); } }, 0, 120000); }
From source file:de.grundid.plusrad.recording.RecordingService.java
private void startLocationUpdates() { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("activityUpdate"); broadcastManager.registerReceiver(broadcastReceiver, intentFilter); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME_PRO_LOCATION_UPDATE, 0, this); }
From source file:com.asc.msigeosystems.prism4d.YGPS.java
/**************** @Override//from w w w . ja v a 2 s .c om public void onNmeaReceived(long timestamp, String nmea) { //create an object with all the fields from the string mNmeaData = mNmeaParser.parse(nmea); //update the UI //updateNmeaUI(mNmeaData); //save the raw data //get the nmea container Prism4DNmeaContainer nmeaContainer = Prism4DNmeaContainer.getInstance(); nmeaContainer.add(mNmeaData); } *******************************/ //*********************** End of Callbacks *******************// //******************** Callback Utilities *****************// // Called by OS when a Listener condition is met // //************************************************************// //Update the UI with satellite status info from GPS protected void setGpsStatus() { if (mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { //location manager is enabled, //update the UI with info from GPS mGpsStatus = mLocationManager.getGpsStatus(mGpsStatus); //get satellite data from GPS Iterable<GpsSatellite> sats = mGpsStatus.getSatellites(); int inSky = 0; int inFix = 0; for (GpsSatellite s : sats) { inSky += 1; if (s.usedInFix()) { inFix += 1; } } //update the UI with the GPS info mSatInSky.setData(inSky); //indicate whether the position is fixed (locked) or not mSatInFix.setData(inFix); if (inFix > 0) { mGpsState.stateLock(); } else { mGpsState.stateOn(); } mTtff.setData(mGpsStatus.getTimeToFirstFix()); } else { //location manager is not enabled, u // pdate the UI with that mGpsState.stateOff(); mSatInFix.setData("no fix"); mSatInSky.setData("gps off"); } mPositionView.postInvalidate(); mSignalView.postInvalidate(); }
From source file:com.jbsoft.farmtotable.FarmToTableActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { progress = new ProgressDialog(this); super.onCreate(savedInstanceState); if (readyToGo()) { setContentView(R.layout.activity_main); SupportMapFragment mapFrag = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); initListNav();//from w w w . j av a 2 s . c om getSupportActionBar().setHomeButtonEnabled(true); sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); getPreferences(sharedPrefs); sharedPrefs.registerOnSharedPreferenceChangeListener(listener); map = mapFrag.getMap(); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // Getting GPS status boolean isNETWORKEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); boolean isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); // If GPS enabled, get latitude/longitude using GPS Services if (isGPSEnabled) { locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, gpsLocationListener); Log.d("GPS Enabled", "GPS Enabled"); if (locationManager != null) { location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (location != null) { latitude = location.getLatitude(); longitude = location.getLongitude(); } } } if (savedInstanceState == null) { CameraUpdate center = CameraUpdateFactory.newLatLng(new LatLng(latitude, longitude)); map.moveCamera(center); } if (NOFM) { //Reverse geocoder to zipcode getZipFromLocation(location, this); //start progress box going //Call api to retrieve Farmers Market from the UDSA site usdaurl = usdaurl + zipcode; } else { nozip = true; } //start progress box going progress.setMessage("Getting Farmers Markets and Other Organic Options in your area:)"); progress.setProgressStyle(ProgressDialog.STYLE_SPINNER); progress.setIndeterminate(true); progress.show(); gplaceurl = placeurl_save; placeurl_save = gplaceurl; if (NOVR) { gplaceurl = gplaceurl + queryvegan; } if (NOOR) { gplaceurl = placeurl_save; gplaceurl = gplaceurl + queryvegetarian; } if (NOFS) { gplaceurl = placeurl_save; gplaceurl = gplaceurl + queryfarms; } if ((NOVR) && (NOOR)) { gplaceurl = placeurl_save; gplaceurl = gplaceurl + queryvegan + "&" + queryvegetarian; } if ((NOVR) && (NOFS)) { gplaceurl = placeurl_save; gplaceurl = gplaceurl + queryvegan + "&" + queryfarms; } if ((NOOR) && (NOFS)) { gplaceurl = placeurl_save; gplaceurl = gplaceurl + queryvegetarian + "&" + queryfarms; } if ((NOVR) && (NOOR) && (NOFS)) { gplaceurl = placeurl_save; gplaceurl = gplaceurl + queryvegan + "&" + queryvegetarian + "&" + queryfarms; } //The Google Places API Text Search Service gplaceurl = gplaceurl + "&location=" + latitude + "," + longitude + "&radius=10&key=AIzaSyA_fzl-7ZkF4EINWhuQ0bcXp3zkdAXZc5o"; //Call Asynch process Api new restAPICall().execute(usdaurl, gplaceurl); } map.setInfoWindowAdapter(new CustomToast(this, null)); // map.setOnInfoWindowClickListener((OnInfoWindowClickListener) map.setMyLocationEnabled(true); CameraUpdate zoom = CameraUpdateFactory.zoomTo(12); map.animateCamera(zoom); }
From source file:com.ternup.caddisfly.activity.SurveyActivity.java
private long saveData() { if (isFormIncomplete()) { return -1; }/*from ww w .j a v a 2 s .c om*/ MainApp mainApp = (MainApp) getApplicationContext(); ContentValues values = new ContentValues(); values.put(LocationTable.COLUMN_DATE, (new Date().getTime())); String featureName = mainApp.address.getFeatureName(); if (featureName == null || featureName.isEmpty()) { return -1; } values.put(LocationTable.COLUMN_NAME, featureName); values.put(LocationTable.COLUMN_STREET, mainApp.address.getThoroughfare() == null ? "" : mainApp.address.getThoroughfare()); values.put(LocationTable.COLUMN_TOWN, mainApp.address.getSubLocality() == null ? "" : mainApp.address.getSubLocality()); values.put(LocationTable.COLUMN_CITY, mainApp.address.getLocality() == null ? "" : mainApp.address.getLocality()); values.put(LocationTable.COLUMN_STATE, mainApp.address.getAdminArea() == null ? "" : mainApp.address.getAdminArea()); values.put(LocationTable.COLUMN_COUNTRY, mainApp.address.getCountryName() == null ? "" : mainApp.address.getCountryName()); values.put(LocationTable.COLUMN_LONGITUDE, mainApp.location.getLongitude()); values.put(LocationTable.COLUMN_LATITUDE, mainApp.location.getLatitude()); values.put(LocationTable.COLUMN_ACCURACY, mainApp.location.getAccuracy()); Bundle bundle = mainApp.address.getExtras(); int sourceType = bundle.getInt("sourceType", 0); String notes = ""; if (mNotesFragment != null) { notes = mNotesFragment.getNotes(); } values.put(LocationTable.COLUMN_SOURCE, sourceType); values.put(LocationTable.COLUMN_NOTES, notes); Uri uri = getContentResolver().insert(LocationContentProvider.CONTENT_URI, values); long id = ContentUris.parseId(uri); PreferencesUtils.setLong(this, R.string.currentLocationId, id); mainApp.address = new Address(Locale.getDefault()); mainApp.location = new Location(LocationManager.GPS_PROVIDER); File file = new File(FileUtils.getStoragePath(this, 0, "", true) + "photo"); FileUtils.deleteFolder(this, id, ""); file.renameTo(new File(FileUtils.getStoragePath(this, id, "", true) + "photo")); return id; }
From source file:com.ibm.mil.readyapps.telco.hotspots.HotSpotActivity.java
private Location initUserMarker() { LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); Location userLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); LatLng userPosition = DEFAULT_LOCATION; // default if no user location exists if (userLocation != null) { userPosition = new LatLng(userLocation.getLatitude(), userLocation.getLongitude()); }/*from ww w . j a v a2s . c o m*/ userMarker = map.addMarker(new MarkerOptions().position(userPosition).anchor(0.5f, 0.5f) .icon(BitmapDescriptorFactory.fromResource(R.drawable.person))); return MapUtils.convertLatLng(userMarker.getPosition()); }
From source file:com.cmput301w17t07.moody.CreateMoodActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_create_mood); UserController userController = new UserController(); userName = userController.readUsername(CreateMoodActivity.this).toString(); setUpMenuBar(this); location = null;//from w w w. j a v a 2 s . c o m date = new Date(); Intent intent = getIntent(); locationText = (TextView) findViewById(R.id.locationText); Description = (EditText) findViewById(R.id.Description); mImageView = (ImageView) findViewById(R.id.editImageView); //try to get picklocation, if it is equal to 1 that means, user just back from map not //other activities try { pickLocation = (int) intent.getExtras().getInt("pickLocation"); } catch (Exception e) { e.printStackTrace(); } if (pickLocation == 1) { tempMood = (Mood) intent.getSerializableExtra("editMood"); bitmap = (Bitmap) intent.getParcelableExtra("bitmapback"); latitude = tempMood.getLatitude(); longitude = tempMood.getLongitude(); address = tempMood.getDisplayLocation(); locationText.setText(address); Description.setText(tempMood.getMoodMessage()); mImageView.setImageBitmap(bitmap); date = tempMood.getDate(); displayAttributes(); } /** * Spinner dropdown logic taken from http://stackoverflow.com/questions/13377361/how-to-create-a-drop-down-list <br> * Author: Nicolas Tyler, 2013/07/15 8:47 <br> * taken by Xin Huang 2017/03/10 <br> */ //Spinner for emotion and socialsituatuion if (pickLocation == 0) { Spinner dropdown = (Spinner) findViewById(R.id.Emotion); String[] items = new String[] { "anger", "confusion", "disgust", "fear", "happiness", "sadness", "shame", "surprise" }; ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, items); dropdown.setAdapter(adapter); dropdown.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { EmotionText = parent.getItemAtPosition(position).toString(); } @Override public void onNothingSelected(AdapterView<?> parent) { Toast.makeText(CreateMoodActivity.this, "Please pick a feeling!", Toast.LENGTH_SHORT).show(); } }); Spinner dropdown_SocialSituation = (Spinner) findViewById(R.id.SocialSituation); String[] item_SocialSituation = new String[] { "", "alone", "with one other person", "with two people", "with several people", "with a crowd" }; ArrayAdapter<String> adapter_SocialSituation = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, item_SocialSituation); dropdown_SocialSituation.setAdapter(adapter_SocialSituation); dropdown_SocialSituation.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { SocialSituation = parent.getItemAtPosition(position).toString(); TextView sizeView = (TextView) findViewById(R.id.SocialText); sizeView.setText(" " + SocialSituation); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); } ImageButton chooseButton = (ImageButton) findViewById(R.id.Camera); ImageButton locationButton = (ImageButton) findViewById(R.id.location); ImageButton PickerButton = (ImageButton) findViewById(R.id.Picker); //click on PickerButton, call the datetimePicker PickerButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { innit(); TimeDialog.show(); } }); chooseButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); startActivityForResult(intent, 1); } catch (Exception e) { Intent intent = new Intent(getApplicationContext(), CreateMoodActivity.class); startActivity(intent); } } }); chooseButton.setOnLongClickListener(new View.OnLongClickListener() { public boolean onLongClick(View view) { try { Intent intent = new Intent("android.intent.action.PICK"); intent.setType("image/*"); startActivityForResult(intent, 0); } catch (Exception e) { Intent intent = new Intent(getApplicationContext(), CreateMoodActivity.class); startActivity(intent); } return true; } }); locationButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); //check available tools List<String> locationList = locationManager.getProviders(true); if (locationList.contains(LocationManager.GPS_PROVIDER)) { provider = LocationManager.GPS_PROVIDER; } else if (locationList.contains(LocationManager.NETWORK_PROVIDER)) { provider = LocationManager.NETWORK_PROVIDER; } else { Toast.makeText(getApplicationContext(), "Please check application permissions", Toast.LENGTH_LONG).show(); } //check the permission if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling Toast.makeText(getApplicationContext(), "Get location failed, Please check the Permission", Toast.LENGTH_SHORT).show(); return; } location = locationManager.getLastKnownLocation(provider); if (location == null) { latitude = 0; longitude = 0; } else { latitude = location.getLatitude(); longitude = location.getLongitude(); } Geocoder gcd = new Geocoder(CreateMoodActivity.this, Locale.getDefault()); try { List<Address> addresses = gcd.getFromLocation(latitude, longitude, 1); if (addresses.size() > 0) address = " " + addresses.get(0).getFeatureName() + " " + addresses.get(0).getThoroughfare() + ", " + addresses.get(0).getLocality() + ", " + addresses.get(0).getAdminArea() + ", " + addresses.get(0).getCountryCode(); locationText.setText(address); } catch (Exception e) { e.printStackTrace(); } } }); //pass users' changes to map, will be passed back locationButton.setOnLongClickListener(new View.OnLongClickListener() { public boolean onLongClick(View view) { int fromCreate = 123; moodMessage_text = Description.getText().toString(); tempMood = new Mood(EmotionText, userName, moodMessage_text, latitude, longitude, null, SocialSituation, date, address); Intent editLocation = new Intent(CreateMoodActivity.this, EditLocation.class); editLocation.putExtra("EditMood", tempMood); editLocation.putExtra("fromCreate", fromCreate); editLocation.putExtra("bitmap", compress(bitmap)); startActivity(editLocation); return true; } }); Button submitButton = (Button) findViewById(R.id.button5); submitButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { moodMessage_text = Description.getText().toString(); MoodController moodController = new MoodController(); // --------------------------- achievements ------------------------------------- AchievementManager.initManager(CreateMoodActivity.this); AchievementController achievementController = new AchievementController(); achievements = achievementController.getAchievements(); achievements.moodCount += 1; achievementController.incrementMoodCounter(EmotionText); achievementController.saveAchievements(); // ------------------------------------------------------------------------------ if (location != null || pickLocation == 1) { //todo can remove these if/else statements that toast message too long. They could // be handled in the controller if (!MoodController.createMood(EmotionText, userName, moodMessage_text, latitude, longitude, bitmap, SocialSituation, date, address, CreateMoodActivity.this)) { Toast.makeText(CreateMoodActivity.this, "Mood message length is too long. Please try again.", Toast.LENGTH_SHORT).show(); } else { Intent intent = new Intent(CreateMoodActivity.this, TimelineActivity.class); startActivity(intent); finish(); } } else { if (!MoodController.createMood(EmotionText, userName, moodMessage_text, 0, 0, bitmap, SocialSituation, date, address, CreateMoodActivity.this)) { Toast.makeText(CreateMoodActivity.this, "Mood message length is too long. Please try again.", Toast.LENGTH_SHORT).show(); } else { Intent intent = new Intent(CreateMoodActivity.this, TimelineActivity.class); startActivity(intent); finish(); } } } }); }