getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
This can be used to suppress the keyboard until the user actually touched the edittext view.
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
String cmd = "cmd.exe /c start ";
String file = "c:\\version.txt";
Runtime.getRuntime().exec(cmd + file);
LocationManager
.LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
double longitude = location.getLongitude();
double latitude = location.getLatitude();
getLastKnownLocation()
doesn't block - which means it will return null
if no position is currently available - so you probably want to have a look at passing a LocationListener
to therequestLocationUpdates()
method instead, which will give you asynchronous updates of your location.private final LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
longitude = location.getLongitude();
latitude = location.getLatitude();
}
}
lm.requestLocationUpdates(LocationManager.GPS, 2000, 10, locationListener);
ACCESS_FINE_LOCATION
permission if you want to use GPS.<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
ACCESS_COARSE_LOCATION
permission for when GPS isn't available and select your location provider with the getBestProvider()
method.ORIENTATION_LANDSCAPE
, ORIENTATION_PORTRAIT
, or ORIENTATION_SQUARE
.
public static int getScreenOrientation(){
return getResources().getConfiguration().orientation;
}
File sdCard = Environment.getExternalStorageDirectory();
File dir = new File (sdcard.getAbsolutePath() + "/dir1/dir2");
dir.mkdirs();
File file = new File(dir, "filename");
FileOutputStream f = new FileOutputStream(file);
...