From reading the documentation for supporting multiple screen sizes, starting with Android 3.2, you can use smallestScreenWidthDp to conditionally set a layout, but is there anything for pre-3.2 devices?
I have a fragment-based layout, and I’d like to show both fragments on the screen if the screen size is greater than 600dp.
This is the code I’m using to set the fragments that I’d like find an alternative for:
public class MyActivity extends FragmentActivity
{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getResources().getConfiguration().smallestScreenWidthDp >= 600) {
finish();
return;
}
if (savedInstanceState == null) {
final DetailFragment details = new DetailFragment();
details.setArguments(getIntent().getExtras());
getSupportFragmentManager().beginTransaction().add(android.R.id.content, details).commit();
}
}
}
As u already said, “SmallestScreenWidthDp” ( http://developer.android.com/guide/practices/screens_support.html ) is the best choice for 3.2 and above. Pre 3.2 devices u could just use the Configuration object, as u did.
in other words:
no there’s (unfortunately) no alternative…