stacktipslab / advance-android-tutorials Goto Github PK
View Code? Open in Web Editor NEWList of Advance Android tutorials as published on https://stacktips.com/topics/android
Home Page: http://stacktips.com
License: Apache License 2.0
List of Advance Android tutorials as published on https://stacktips.com/topics/android
Home Page: http://stacktips.com
License: Apache License 2.0
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.id.button1, menu);
return true;
}
retireveLocationButton = (Button) findViewById(R.id.retrieve_Location_Button);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
MINIMUM_TIME_BETWEEN_UPDATES,
MINIMUM_DISTANCE_CHANGE_FOR_UPDATES,
new MyLocationListener()
);
Im trying to build a blog feed activity using the source from your FeedReader and I'm using github to host the json xml file and it keeps crashing. If i past in your original url for the json file it works but mine does not. I also copied the xml from your url and pasted it in my github. any recommendations or thoughts?
package com.example.gpstracking;
import android.app.Activity;
import android.location.Criteria;
import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.location.LocationListener;
import android.util.Log;
import android.view.Menu;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity implements LocationListener {
LocationManager locationManager;
String provider;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Getting locationManager object
locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
//creating an empty criteria object
Criteria Criteria = new Criteria();
//Getting the name of provider that meet the criteria
provider = locationManager.getBestProvider(Criteria, false);
if(provider!=null && !provider.equals("")){
Location location = locationManager.getLastKnownLocation(provider);
locationManager.requestLocationUpdates(provider ,800000,1, this );
if(location!= null)
onLocationChanged(location);
else
Toast.makeText(getBaseContext(),
"Location can't be found" ,Toast.LENGTH_LONG)
.show();
}
else
{
Toast.makeText(getBaseContext(), " No provider found" , Toast.LENGTH_SHORT).show();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@OverRide
public void onLocationChanged(Location location) {
//Getting reference to tv_Longitude
TextView tvLongitude = (TextView)findViewById(R.id.tv_longitude);
tvLongitude.setText("Longitude:" + location.getLongitude());
// Getting reference to tv_Latitude
TextView tvLatitude = (TextView)findViewById(R.id.tv_latitude);
tvLatitude.setText("Latitude:" + location.getLatitude());
}
@OverRide
public void onProviderDisabled(String provider){
Log.d("Latitude","disable");
}
@OverRide
public void onProviderEnabled(String provider){
Log.d("Latitude","enable");
}
@OverRide
public void onStatusChanged(String provider , int status, Bundle extras) {
Log.d("Latitude","status");
}
}
Please specify the license for these samples, in case folks want to use snippets in their own projects.
package com.example.gpstracking;
import android.app.Activity;
import android.location.Criteria;
import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.location.LocationListener;
import android.util.Log;
import android.view.Menu;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity implements LocationListener {
LocationManager locationManager;
String provider;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Getting locationManager object
locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
//creating an empty criteria object
Criteria Criteria = new Criteria();
//Getting the name of provider that meet the criteria
provider = locationManager.getBestProvider(Criteria, false);
if(provider!=null && !provider.equals("")){
Location location = locationManager.getLastKnownLocation(provider);
locationManager.requestLocationUpdates(provider ,800000,1, this );
if(location!= null)
onLocationChanged(location);
else
Toast.makeText(getBaseContext(),
"Location can't be found" ,Toast.LENGTH_LONG)
.show();
}
else
{
Toast.makeText(getBaseContext(), " No provider found" , Toast.LENGTH_SHORT).show();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@OverRide
public void onLocationChanged(Location location) {
//Getting reference to tv_Longitude
TextView tvLongitude = (TextView)findViewById(R.id.tv_longitude);
tvLongitude.setText("Longitude:" + location.getLongitude());
// Getting reference to tv_Latitude
TextView tvLatitude = (TextView)findViewById(R.id.tv_latitude);
tvLatitude.setText("Latitude:" + location.getLatitude());
}
@OverRide
public void onProviderDisabled(String provider){
Log.d("Latitude","disable");
}
@OverRide
public void onProviderEnabled(String provider){
Log.d("Latitude","enable");
}
@OverRide
public void onStatusChanged(String provider , int status, Bundle extras) {
Log.d("Latitude","status");
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.