question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tns run android enables auto rotate on device

See original GitHub issue

Tell us about the problem

When installing an app using tns run android , auto rotate of device is turned on every time.

Which platform(s) does your issue occur on?

Android (iOS not tested)

Please provide the following version numbers that your issue occurs with:

  • CLI: 3.0.3
  • Cross-platform modules: (check the ‘version’ attribute in the node_modules/tns-core-modules/package.json file in your project)
  • Runtime(s): android

Please tell us how to recreate the issue in as much detail as possible.

  1. Open powershell(windows)
  2. do tns create appName
  3. cd to directory
  4. turn off auto rotate on android device
  5. tns run android

this turns auto rotate on.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
Plamen5kovcommented, Aug 3, 2017

Based on popular vote: removing monkey from implementation and replacing it with am tool.

1reaction
petekanevcommented, Jul 26, 2017

@Plamen5kov I don’t like the idea of forcing device rotation manually, for one, you may have to know of the original state, to be able to do it properly, and I’ve also noticed that the adb monkey tool doesn’t always unlock automatic rotation.

In order to determine which Activity to send a MAIN intent to using the Activity Manager (adb am), we could do a package dump, and grep the Activity Resolver Table. For an application with a single activity it looks like this:

  Activity Resolver Table:
    Non-Data Actions:
        android.intent.action.MAIN:
          2e5610f org.nativescript.volunteerupapp/com.tns.NativeScriptActivity filter c0aef3
            Action: "android.intent.action.MAIN"
            Category: "android.intent.category.LAUNCHER"
            AutoVerify=false

If I executed adb shell pm dump org.nativescript.volunteerupapp | grep -A 1 MAIN I would end up with just this, which is fairly parseable:

        android.intent.action.MAIN:
          2e5610f org.nativescript.volunteerupapp/com.tns.NativeScriptActivity filter c0aef3
            Action: "android.intent.action.MAIN"
            Category: "android.intent.category.LAUNCHER"

There is an alternative to using pm dump to get the Activity Resolver table, and that’s using cmd package resolve-activity --brief org.nativescript.volunteerupapp, which unfortunately appears to be unavailable on devices API 24 or lower. Following is the result when the command is executed:

priority=0 preferredOrder=0 match=0x108000 specificIndex=-1 isDefault=false
org.nativescript.volunteerupapp/com.tns.NativeScriptActivity
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to automatically rotate your screen - Google Support
Open your device's Settings app Settings app . · Select Accessibility. · Select Auto-rotate screen.
Read more >
Application enables orientation change button is status bar
I have no troubles with orientation changing. · Alright, just that when I added the package to my app and with the sample...
Read more >
Android: How To Turn On Screen Rotation (Three Methods)
Today we will be talking about how to allow screen rotation on your Android device so that you can rotate your screen for...
Read more >
How to control the screen rotation on an Android device
Information · Go to 'Device'> 'Display' · Uncheck 'Allow Screen Rotation' (on by default) · Select the desired screen rotation at the field...
Read more >
How to Fix Auto Rotate Not Working on Android
If you've enabled the automatic screen rotation option from your phone's Quick Settings menu, try turning on that option from the Settings app ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found