[ 
https://issues.apache.org/jira/browse/CB-10837?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15190764#comment-15190764
 ] 

dcz.switcher commented on CB-10837:
-----------------------------------

until this bug was resolved, I use a hook
here is the code if it can help someone

note : I use cheerio lib to parse the Manifest file, so you have to install it :
npm install cheerio
note 2 : if you never used hooks : 
1 - put this script in a subfolder call after_prepare/ in hooks/ (with the name 
you want, for example : hooks/after_prepare/android_orientation.js)
2 - give to the hooks folder execute rights : chmod -R a+x hooks/

{code:javascript}
#!/usr/bin/env node
var fs = require('fs'),
    cheerio = require('cheerio');

var manifestPath = 'platforms/android/AndroidManifest.xml';

var manifest = fs.readFileSync(manifestPath, 'utf8')
var $ = cheerio.load(manifest, {xmlMode : true});

$('activity').each(function (i, el) { 
   if (el.attribs['android:name'] && el.attribs['android:name'] === 
"MainActivity"){
        $(this).attr('android:screenOrientation', 'nosensor');   
       return;
  }
});

fs.writeFileSync(manifestPath, $.html(), 'utf8');
{code}

> platform specific orientation preference is not supported
> ---------------------------------------------------------
>
>                 Key: CB-10837
>                 URL: https://issues.apache.org/jira/browse/CB-10837
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 5.4.1
>            Reporter: dcz.switcher
>              Labels: build
>
> Hi,
> I want to set Manifest.xml activity with android:screenOrientation="nosensor"
> http://developer.android.com/guide/topics/manifest/activity-element.html#screen
> In cordova doc : 
> Additionally, you can specify any platform-specific orientation value if you 
> place the <preference> element within a <platform> element:
> So, I do it in config.xml
> <platform name="android">
>         <preference name="orientation" value="nosensor" />
> </platform>
> but on build : 
> Unsupported global orientation: nosensor. Defaulting to value: default



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to