简体   繁体   中英

Separate apks for same app for Phone and Tablet on Google play

I have an app which has 2 different designs depending on the device. I want to keep an orientation lock (landscape on tablet and portrait on phone). I decided to create separate apks and upload it on Google play and the users download the app depending on the device they have. Is this approach advisable? If yes, what steps can I follow to make sure everything works fine?

Any help would be appreciated.

The Google Play Developer Console provides two modes for managing the APKs associated with your application: simple mode and advanced mode. You can switch between these by clicking the link at the top-right corner of the APK files tab.

Simple mode is the traditional way to publish an application, using one APK at a time. In simple mode, only one APK can be activated at a time. If you upload a new APK to update the application, clicking "Activate" on the new APK deactivates the currently active APK (you must then click Save to publish the new APK).

Advanced mode allows you to activate and publish multiple APKs that are each designed for a specific set of device configurations. However, there are several rules based on the manifest declarations in each APK that determine whether you're allowed to activate each APK along with others. When you activate an APK and it violates one of the rules, you will receive an error or warning message. If it's an error, you cannot publish until you resolve the problem; if it's a warning, you can publish the activated APKs, but there might be unintended consequences as to whether your application is available for different devices. These rules are discussed more below.

http://developer.android.com/google/play/publishing/multiple-apks.html

I decided to create separate apks and upload it on Google play and the users download the app depending on the device they have. Is this approach advisable?

Some of tablet & phone have same resolution & size in this case Google Play allow to install TABLET APK in Phone. so its break you logic. if you are able to stop this type if scenario then its good idea to upload both APK for Tablet & Phone.


Use same JAVA code and create two different design for tablet and Phone. check this Supporting Multiple Screen from android developer. upload one apk on Google Play for both Phone & Tablet.

You can make your app UI responsive it work well on all android devices .It is not advisable to make different apk for different device. For responsive design of android app check these links- http://android-developers.blogspot.in/2011/07/new-tools-for-managing-screen-sizes.html http://www.androiduipatterns.com/2011/11/design-patterns-for-responsive-android.html http://mdswanson.com/blog/2013/12/11/responsive-layouts-in-android.html

You don't need separate APK for just that. Find out if the device is phone or tablet by the following code

mFile = context.getFilesDir().getAbsoluteFile();
mDisplayMetrics = context.getResources().getDisplayMetrics();
connMan = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
final double x = Math.pow(mDisplayMetrics.widthPixels / mDisplayMetrics.xdpi, 2);
final double y = Math.pow(mDisplayMetrics.heightPixels / mDisplayMetrics.ydpi, 2);
mScreenInches = Math.sqrt(x + y);

if mScreenUnches < 5 its phone

override onConfigurationChanged and restrict based on the screen size

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

    // Checks the orientation of the screen
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
        Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM