BASIC

Author Topic: Android screen orientation  (Read 2400 times)

Offline Paul Smith

  • Mr. Polyvector
  • ***
  • Posts: 109
    • View Profile
Android screen orientation
« on: 2017-Apr-24 »
Written a few app for android over the years.today I started a new one from scratch using the latest GLB.
however its upside down, loading old project from older versions and compiling works.

no matter what project/options sizes i try makes no difference in android.

a simple  test
print"test",100,100
showscreen
mousewait

shows sideways

any Ideas, have I forgot something?
Amstrad CPC 6128, ATARI STE.
Acer  SW5-173 & AMD FX 8350/1050Ti

Online spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3684
    • View Profile
    • Space Fractal
Re: Android screen orientation
« Reply #1 on: 2017-Apr-24 »
Don't use set orientation which is set automatic in newer android extras versions.

It's also respect was set in Androidmanifest.xml orientations as well. By default landscape only. This due possible to support example android TV and game pads.
« Last Edit: 2017-Apr-25 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4233
    • View Profile
    • Portfolio
Re: Android screen orientation
« Reply #2 on: 2017-Apr-25 »
Like Space said, it should work out of the box on landscape mode without any command...and tell you what, it works like a charm, it even auto rotates if you flip the phone.
One thing that comes to mind, consider creating a landscape resolution, like 1280x720 instead of otherwise (720x1280).

My older code had to be adapted a bit to it, but very little, just the resolution set, no hassle at all.

Offline Paul Smith

  • Mr. Polyvector
  • ***
  • Posts: 109
    • View Profile
Re: Android screen orientation
« Reply #3 on: 2017-Apr-26 »
Sorted, changed sensorLandscape to sensorPortrait. ( I guess the sensor bit is for the flip in Landscape mode)
It would be nice to have this option in GLB directly, rather then compiling, changing the XML file then recompiling again.

Cant wait till the next update and hope it fixes KEYWAIT
mousewait has slowdown issues on Windows and Keywait just gets ignored.

Is the PLATFORMINFO$(ID) key totally unique, Ive written a lock on my app to restrict parts from running with out a valid key.

 
Amstrad CPC 6128, ATARI STE.
Acer  SW5-173 & AMD FX 8350/1050Ti

Online spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3684
    • View Profile
    • Space Fractal
Re: Android screen orientation
« Reply #4 on: 2017-Apr-26 »
The Id is a random based key, not based on hardware. You not allowed to do that on Android and iOS anymore. It's also limited on Windows. Don't use it to restrict users. It's not trusted. and If you ask me, it's should been deprecated. Sorry about that.

Keywait should not been used on Android. Use GameInput Api instead for game pad supportm

Orientation is just what how android works. Cannot do anything with it at all. Same with iOS, where orientation is set in xcode option. You only do that once anyway.

Sensor portrait can also been flipped on Tables, which is right way to do.
« Last Edit: 2017-Apr-26 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1779
    • View Profile
    • Homepage
Re: Android screen orientation
« Reply #5 on: 2017-Apr-26 »
That's a good idea, does anyone have time to put together a "Best practises coding guide" for Android and iOS? I think that would be incredible useful to get started with those platforms. There seems to be all sorts of edge cases that needs special treatment and a lot of compile/upload/test-cycles to get working right.

I know I would love such a guide :-)

Offline dreamerman

  • Global Moderator
  • Dr. Type
  • *******
  • Posts: 288
    • View Profile
    • my personal website
Re: Android screen orientation
« Reply #6 on: 2017-Apr-26 »
Also use GLB_ON_LOOP and all that stuff...
For now to set landscape/portrait I was using different resolutions in project options.. something like 9999x9998 for landscape, and reversed for portrait, tested on older OS versions, all was working fine..

One thing about device ID's, how is that PLATFORMINFO$(ID) generated? Currently on those systems there is so many id generating options for apps made with standard SDK's. Recommended way to generate random guid for android is:
Code: GLBasic [Select]
String uniqueID = UUID.randomUUID().toString();
There is also Advertising ID that can be used to track ads (similar thing is on WindowsPhone). I never used Android Extras in-app purchase code, how there particular device/user is recognized?

Such 'coding guide' would be great as sometimes it's hard to track little things that can cause problems on mobile devices. Even in form of forum topics..
Check my source code editor for GLBasic - link

Online spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3684
    • View Profile
    • Space Fractal
Re: Android screen orientation
« Reply #7 on: 2017-Apr-27 »
What set in resolution might not respected as orientation anymore, but its should just detect the current resolution and use that. This is the way to do that on Android. Im have simply just used orientation as the originally intended on that platform. Also SETORIENTATION() can start in any value in any orientation. This is the reason im fixed that orientation, because its was not respected that value in old glbasic and then failed on some devices.

You can do set on orientation needed as im wrote in androidmanifest.xml:
https://developer.android.com/guide/topics/manifest/activity-element.html

in iOS, both orientation simulation does still NOT work. But you can do set it to one orientation (example portrait) as SETORIENTATION() here would allways start as 0, unlike Android. SO you can set it to portrait only and simulate that. but if you dont need both orientation, then use xCode orientation features and let the system do that for you. Old orientation code from iOS7 and down is removed as well.

Also dont except ID to do a real ID. Since its not a real ID, then im fell the command is very wrong and hence its should been removed and gone for ALL platforms. There has also been heavy debate about that hardware ID. Also randomUUID is not a real ID. Its best to change it to different than "ID", etc call it "SEED", which is set once per installation.

« Last Edit: 2017-Apr-27 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.