I need to detect an orientation of an device, for that I have written a code below. But I am unable get orientation. Please help.
mOrientationListener = new OrientationEventListener(getApplicationContext())
{
@Override
public void onOrientationChanged(int orientation)
{
if(orientation == 1)
{
setContentView(R.layout.activity_main_portrait);
}
else
{
setContentView(R.layout.activity_main_landscape);
}
}
};
0 comments:
Post a Comment