16 Replies Latest reply on Jan 10, 2018 1:19 PM by beni27467886

    app work on mobile portrait only & tablet work both portrait and landscape?

    gnanaprakashmarimuthu

      Im newer to phonegap ,now i'm build the app android app it's support android mobile & Tablet? app work on mobile portrait only & tablet work both portrait and landscape? how to d/w its mobile or tablet ? is there any chance to add config.xml file?please help me out!!!

        • 1. Re: app work on mobile portrait only & tablet work both portrait and landscape?
          VectorP Level 4

          I wonder what you consider a "mobile" and what you consider a "tablet".

          Is it determined by screen resolution? Screen dimensions? Device functionality? Make and model? Something else?

          • 3. Re: app work on mobile portrait only & tablet work both portrait and landscape?
            gnanaprakashmarimuthu Level 1

            Please check this one window.isTablet is a javascript its show you  mobile or tablet? You need to write the code under the onDeviceReady .

            • 4. Re: app work on mobile portrait only & tablet work both portrait and landscape?
              VectorP Level 4

              OK. That's an API function of the isTablet plugin:

              uk.co.workingedge.phonegap.plugin.istablet

               

              Did you include that plugin in your config? Does it appear in the Plugins tab of your app's PGB page?

              • 5. Re: app work on mobile portrait only & tablet work both portrait and landscape?
                gnanaprakashmarimuthu Level 1

                ya exactly i used the same link only & find the result device mobile or tab. if device mobile means orientations screen lock app must work portrait only? still i'm searching not yet the solution.in config.xml added

                <preference name="orientation" value="default" />

                please help me out

                • 6. Re: app work on mobile portrait only & tablet work both portrait and landscape?
                  VectorP Level 4

                  if device mobile means orientations screen lock app must work

                  portrait only?

                   

                  No.

                  Is your zip file for PGB available online somewhere, so forum participants can have a look?

                  • 7. Re: app work on mobile portrait only & tablet work both portrait and landscape?
                    gnanaprakashmarimuthu Level 1
                    Config.xml i added the following lines

                     

                    <?xml version='1.0' encoding='utf-8'?>

                    <widget id="com.mgp.in" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">

                        <name>Screen Orientation</name>

                        <description>

                           How to screen lock android mobile.

                        </description>

                        <author email="dave@workingedge.co.uk" href="http://www.workingedge.co.uk/dave">

                               Gnanaprakash

                        </author>

                        <content src="index.html" />

                        <access origin="*" />

                       <preference name="DisallowOverscroll" value="true" />

                        <preference name="android-minSdkVersion" value="14" />

                        <preference name="orientation" value="default" />

                        <plugin name="cordova-plugin-battery-status" source="npm" spec="~1.1.1" />

                        <plugin name="cordova-plugin-camera" source="npm" spec="~2.1.1" />

                        <plugin name="cordova-plugin-media-capture" source="npm" spec="~1.2.0" />

                        <plugin name="cordova-plugin-console" source="npm" spec="~1.0.2" />

                        <plugin name="cordova-plugin-contacts" source="npm" spec="~2.0.1" />

                        <plugin name="cordova-plugin-device" source="npm" spec="~1.1.1" />

                        <plugin name="cordova-plugin-device-motion" source="npm" spec="~1.2.0" />   

                        <!--plugin name="cordova-plugin-device-orientation" source="npm" spec="~1.0.2" /-->

                        <plugin name="cordova-plugin-dialogs" source="npm" spec="~1.2.0" />

                        <plugin name="cordova-plugin-file" source="npm" spec="~4.1.1" />

                        <plugin name="cordova-plugin-file-transfer" source="npm" spec="~1.5.0" />

                        <plugin name="cordova-plugin-geolocation" source="npm" spec="~2.1.0" />

                        <plugin name="cordova-plugin-globalization" source="npm" spec="~1.0.3" />

                        <plugin name="cordova-plugin-inappbrowser" source="npm" spec="~1.3.0" />

                        <plugin name="cordova-plugin-media" source="npm" spec="~2.2.0" />

                        <plugin name="cordova-plugin-network-information" source="npm" spec="~1.2.0" />

                        <plugin name="cordova-plugin-splashscreen" source="npm" spec="~3.2.1" />

                        <plugin name="cordova-plugin-statusbar" source="npm" spec="~2.1.2" />

                        <plugin name="cordova-plugin-vibration" source="npm" spec="~2.1.0" />

                       <plugin name="cordova-plugin-whitelist" version="1" />

                       <plugin name="uk.co.workingedge.phonegap.plugin.istablet" version="1" />

                      

                       <allow-intent href="http://*/*" />

                       <allow-intent href="https://*/*" />

                       <allow-intent href="tel:*" />

                       <allow-intent href="sms:*" />

                       <allow-intent href="mailto:*" />

                       <allow-intent href="geo:*" />

                        <!-- i can't set -->

                        <!--Android mobile must work Portrait only / tablet work both -->

                       <platform name="android">

                           <allow-intent href="market:*" />

                       </platform>

                     

                     

                      <!-- For IOS find Orientations and fix Iphone work Portrait only / Ipad work both -->

                           <platform name="ios">

                          <allow-intent href="itms:*"/>

                          <allow-intent href="itms-apps:*"/>     

                          <config-file platform="ios" target="*-Info.plist" parent="UISupportedInterfaceOrientations">

                             <array>

                                <string>UIInterfaceOrientationPortrait</string>

                             </array>

                          </config-file>

                          <config-file platform="ios" target="*-Info.plist" parent="UISupportedInterfaceOrientations~ipad">

                             <array>

                                <string>UIInterfaceOrientationLandscapeLeft</string>

                                <string>UIInterfaceOrientationLandscapeRight</string>

                             </array>

                          </config-file>     

                       </platform>

                    </widget>

                     

                    Above the lines used in config.xml,instead of in javascript i added window.isTablet, its can find mobile or tablet. but my issues is how to fix Android mobile must work Portrait only / tablet work both ? Android only can't to set the screen lock? . In ios device its easy to find and fix orientation.Please help me out any one

                    • 8. Re: app work on mobile portrait only & tablet work both portrait and landscape?
                      VectorP Level 4

                      I have no idea what the problem is, that you are attempting to solve by setting the screen orientation for 'mobile' and 'tablet' (whatever that is) differently.

                      But you could use this plugin:

                      cordova-plugin-screen-orientation

                       

                      BTW: you should check:

                      - whether or not you really need all those plugins

                      - whether or not it's really necessary to pin those plugins to older (or even non-existent) versions.

                      • 9. Re: app work on mobile portrait only & tablet work both portrait and landscape?
                        gnanaprakashmarimuthu Level 1

                        I tried suggested answers but not yet the result, screen locking not working android mobile. please any one share some lines of code for phonegap build.

                        • 10. Re: app work on mobile portrait only & tablet work both portrait and landscape?
                          kerrishotts Adobe Community Professional

                          My advice: don't lock orientations. Build your app such that it is responsive to any form factor, including phones in landscape mode.

                           

                          Furthermore, the isTablet plugin you're referencing doesn't do anything to lock the orientation -- it just lets you determine if the app is running on a tablet or not. What you do after that is up to you -- if you must lock the orientation, use the plugin to which @VectorP linked. The documentation explains clearly how to lock to a specific orientation.

                           

                          I also took a quick look at the plugin's code, and I don't see how it will reliably indicate if the device is a tablet or a phone -- it appears to go solely by resolution and dpi. That's a rapidly shifting target, and I suspect would return incorrect results for a good number of phones as well.

                           

                          Again, though: please don't. It's not ideal for your users (especially those with large phones), and your app must already support some responsive design if it can handle portrait & landscape orientation on a tablet. There's very little reason to limit that feature on a phone.

                          • 11. Re: app work on mobile portrait only & tablet work both portrait and landscape?
                            gnanaprakashmarimuthu Level 1

                            The really problem for me is

                            The app has to work only on portrait for android phone and for tablet it has to support both the orienations such as portrait and landscape.

                            This option works for ios platform (iphone and ipad)

                            I tried to use the plugin suggested by @VectorP, I installed the plugin and used the code, but after i build the apk and installed then the plugin code to lock the orientation to only portrait for my android phone doesn't work at all.

                             

                            Am I missing something in my config or any thing, please let me know.

                            • 12. Re: app work on mobile portrait only & tablet work both portrait and landscape?
                              VectorP Level 4

                              the plugin code to lock the orientation to only portrait for my android phone doesn't work at all.

                              What device did you test it on?

                              What did the isTablet plugin consider this device to be?

                              How would you distinguish between 'mobile' and 'tablet' if you had no such plugin?

                               

                              The app has to work only on portrait for android phone and for tablet it has to support both the orienations

                              Kerri replied to that, and implicitly asked: "why, oh why?"   Pinning the orientation to portrait only for phones appears to be a wonderful solution....but for which problem?

                              1 person found this helpful
                              • 13. Re: app work on mobile portrait only & tablet work both portrait and landscape?
                                gnanaprakashmarimuthu Level 1

                                I;m doing a flash card app,if app mobile app support landscape means ,its images not look well and also .so only i need to lock my screens.

                                • 14. Re: app work on mobile portrait only & tablet work both portrait and landscape?
                                  kerrishotts Adobe Community Professional

                                  Ok -- but why can't flashcards work in landscape orientation? The card might be smaller, perhaps, but most people have a hidpi display, so the card should render sharply. Alternatively, you could build cards that work well in a landscape orientation. Furthermore, there are lots of "phablets" out there with pretty expansive screens and centering the original flashcard would probably work just fine.

                                   

                                  Not trying to make more work for you, but I do urge you to consider alternative methods instead of locking the orientation.

                                  • 15. Re: app work on mobile portrait only & tablet work both portrait and landscape?
                                    gnanaprakashmarimuthu Level 1

                                    Thanks to every one for commenting & helping .

                                     

                                    But user feel images is looking very small,its nothing to read and not look well, so only i trying to screen lock.its possible in iphone and ipad,i already done it.so only user's asking repeat.

                                    • 16. Re: app work on mobile portrait only & tablet work both portrait and landscape?
                                      beni27467886

                                      I feel like this is a kind of strange and forceful question, @kerrishotts.
                                      I myself am in the exact same situation right now. There are a great many reasons for apps to be wanted in portrait mode on phones and landscape on tablet.

                                       

                                      For a fact, users to tend to prefer their phones in portrait mode and their tablets in landscape mode.

                                       

                                      I myself am currently working on an app that simply wouldn't have the required space on a landscaped phone. It does, however, have this space on a tablet, which is why I'm looking for a solution to this question as well.

                                       

                                      It has been requested by the users themselves to lock it in portrait mode, since many other apps they use do it as well. They get annoyed that they have to turn off their screen-rotation to use my app because it's simply incredibly hard to use in landscape mode on a phone.

                                       

                                      You are currently commenting on application design instead of looking at the problem. I feel like that is not very objective.