Skip to main content

Featured

Android studio “SDK tools directory is missing”

Following 2 possible solutions will resolve this problem :  Solution1 : To fix the problem, it was required that I list the path to my corporate PAC file by using  Configure -> "Appearance and Behavior" -> System Settings -> HTTP Proxy . I selected "Automatic proxy configuration url:" Delete your  ~/.Android*  folders (losing all of your settings :/). Run Android Studio. It will show you a welcome wizard where it tries to download the SDK again (and fails due to my rubbish internet). Click the X on the wizard window. That will enable you to get to the normal welcome dialog. Go to Settings->Project Defaults->Project Structure and change the Android SDK location to the correct one. Solution 2 : To fix the problem, it was required that I list the path to my corporate PAC file by using  Configure -> "Appearance and Behavior" -> System Settings -> HTTP Proxy . I selected "Automatic proxy configuration url:...

Code to handle Orientation changes in Activity/FragmentActivity,in Android


@Override

public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);

if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {


Toast.makeText(
this, "portrait", Toast.LENGTH_SHORT).show();

imageView_parkingHero.setVisibility(View.GONE);
//mGridViewPortrait.setVisibility(View.VISIBLE);
//mGridViewLandscape.setVisibility(View.GONE);

}
else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {

Toast.makeText(

this, "landscape", Toast.LENGTH_SHORT).show();
imageView_parkingHero.setVisibility(View.VISIBLE);
// mGridViewPortrait.setVisibility(View.GONE);
//mGridViewLandscape.setVisibility(View.VISIBLE);
}
 Note: place this method on outside of ur onCreate() method...
 
 
 
By using above code u get some issue of:
-->  My image not displayed ,when user logged in Landscape mode not in Portrait mode(means Login screen will be in Landscape mode and user press th Login button in Landscape mode and after Login InnerScreen will be Displayed in Landscape mode .Then that time this above code will not work ..
It works only user login in Portrait mode and after login He rotates the screen to Landscape then only my Image displayed,otherwise not.
 
For fixing this issue i used above code with below code:
 //Call this method from onCreate() method of Ur Activity
public void  getScreenOrientation()
{
Display getOrient = getWindowManager().getDefaultDisplay();
//int orientation = Configuration.ORIENTATION_UNDEFINED;
/*if(getOrient.getWidth()==getOrient.getHeight()){
orientation = Configuration.ORIENTATION_SQUARE;
} else{ */

if(getOrient.getWidth() < getOrient.getHeight()){
//orientation = Configuration.ORIENTATION_PORTRAIT;
imageView_parkingHero.setVisibility(View.GONE);
}
else {
//orientation = Configuration.ORIENTATION_LANDSCAPE;
imageView_parkingHero.setVisibility(View.VISIBLE);
}
//}
//return orientation;
}
}


Comments