I've search a lot and don't find the right information for that. I have 2 different activities in my project. At start it was 2 different application, one for mobile and one for tablet. I want to mixe them to get one APK only. So when they where separate it was easy, but mixing the 2 manifest i not for me.I would like to be able to have 2 different activity and the right one launch if this is a mobile and the other if it is a tablet.
Anybody have an example of a manifest that can do it?
To Extend slayton's answer, in the splash (or launcher activity with no interface), you will need to detect whether it is a tablet. You will need to make you're own determination what is considered a tablet. I assume that you are thinking of screen size. Here is a simple example that I got from here: http://groups.google.com/group/android-developers/browse_thread/thread/d6323d81f226f93f
It uses the magic screen size > 6 inches to determine it is a tablet.
public boolean isTablet() {
try {
// Compute screen size
DisplayMetrics dm = context.getResources().getDisplayMetrics();
float screenWidth = dm.widthPixels / dm.xdpi;
float screenHeight = dm.heightPixels / dm.ydpi;
double size = Math.sqrt(Math.pow(screenWidth, 2) +
Math.pow(screenHeight, 2));
// Tablet devices should have a screen size greater than 6 inches
return size >= 6;
} catch(Throwable t) {
Log.error(TAG_LOG, "Failed to compute screen size", t);
return false;
}
Once the launcher activity determines it is a tablet or not, just launch the appropriate activity.
Lets say you currently have two activities, PhoneActivity and TabletActivity. Create a third activity called SplashActivity. Think of SplashActivity as a splash screen or launcher that is only running for a split second. When your app is launched SplashActivity launches, detects if the device is a phone or tablet and then launches the appropriate activity (PhoneActivity or TabletActivity).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With