Wednesday 20 March 2013

To pass different activity in tablet and phone android

In this, I am  going to discuss about how to use different activity used  in Tablet and phone. I will show you the structure how it will look. You can use it based on your requirement.

in res->values->bool.xml


<?xml version="1.0" encoding="utf-8"?>
<resources>
    <bool name="isTabletDevice">false</bool>
</resources>


Main.java


         boolean tabletDeviceSize = getResources().getBoolean(R.bool.isTabletDevice);
if (tabletDeviceSize) {



Intent intent = new Intent(Main.this,
B.class);
startActivity(intent);

}

else
{

               Intent intent = new Intent(Main.this,
C.class);
                 startActivity(intent);

}
Happy coding..