Android Tutorial OUYA-specific tweaks

Your apps will run on OUYA just fine, normally.

It has no sensors. This includes microphone (so no voice recognition), gyroscope, compass, accelerometers, orientation, light. It has nada. It also has no telephony features (but you should be used to that for most tablets)

You only have to support 2 resolutions in landscape orientation, 720p and 1080p. And you get fullscreen access, no bloody menu/nav/action bars.

The controller is actually really easy to use, it just sends keyboard events!
KeyCodes.KEYCODE_DPAD_CENTER KeyCodes.KEYCODE_DPAD_DOWN KeyCodes.KEYCODE_DPAD_LEFT KeyCodes.KEYCODE_DPAD_RIGHT
82=OUYA button
96=O
99=U
100=Y
97=A

102=L1
103=R1
104=L2
105=R2
106=L3
107=R3

The touchpad only sends mouse down/up events. You can't use gestures with it, since dragging just moves the cursor. No long-click either

To get it to show in the proper part of it's menu, you need a 732*412 PNG named ouya_icon.png (set to read-only!) in YOURPROJECT\Objects\res\drawable-xhdpi and to add this code to the manifest editor

B4X:
AddApplicationText(<activity android:name=".NAMEOFYOURACTIVITY" android:label="NAME OF YOUR APP">
  <intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
    <category android:name="tv.ouya.intent.category.GAME"/>
  </intent-filter>
</activity>)

And it's easy to detect if the device is an OUYA

B4X:
IsOuya=Model(0).EqualsIgnoreCase("OUYA")
Sub Model(ID As Int) As String 
   Dim P As Phone
   Select Case ID
         Case 0: Return P.Manufacturer 
         Case 1: Return P.Model
         Case 2: Return P.Product 
   End Select
end sub
 

dibb3386

Member
Licensed User
Longtime User
Good stuff :) I was hoping that the ouya wouldnt be any hassle with b4a. Thanks for the information. Bookmarked! :)
 
@NeoTechni

I've got several questions. For reference: I am new to Basic4Android, Android, XML and Java.

1) How do you set the screen resolution? I don't see the ones you reference under Layout in the Abstract Designer. Am I supposed to choose Match Connected Device?

2) How do I include the icon you mention? The folder doesn't exist. When I create it and the file, Basic4Android wipes it out when I compile the project.

3) Is the package name supposed to be before .NAMEOFYOURACTIVITY in the xml?

Here is what I have been doing.

Installation:
I create the apk using Basic4Android. I then download it to the OUYA through its web browser. Then I install it.

First Observation:
Without your xml and the icon you mentioned, I get the default android icon with the correct application name. When I click on it, something opens and closes very fast.

Second Observation:
With you xml and without the icon you mentioned, I get nothing to click on.

Suggestions?
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
Images you add to the folders need to be set to write-only to tell b4a not to erase them
I dont use the abstract designer so i dont know. But there is an option in ouya's make /settingsmenu somewhere that gives you the exact settings to use
Do not include the package name, just the name of the activity

With the xml/icon i suggest, itll show in the play menu not make
 
Thanks NeoTechni.

I played with it some more and got some answers for myself.

2) Basic4Android Menu --> Project --> Choose Icon --> Then point it to where ever you stored your icon on your computer.

First Observation:
I discovered through debugging with the emulator that there was a problem with a library that I created. I overlooked the JRE version necessary for exporting the JAR. :sign0104: When I fixed that, it worked on the emulator and worked on the OUYA.

Second Observation:
I was expecting the app icon to appear under the Build Menu on the OUYA. It was actually popping up under the Play Menu.
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
1080p's settings:
density: 2.0
densityDpi: 320
width: 1920
height: 1080
scaledDensity: 2.0
 

JakeBullet70

Well-Known Member
Licensed User
Longtime User
I am having a problem running my app when compiled with

B4X:
AddApplicationText(<activity android:name=".NAMEOFYOURACTIVITY" android:label="NAME OF YOUR APP">
  <intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
    <category android:name="tv.ouya.intent.category.GAME"/>
  </intent-filter>
</activity>)

in the manifest file.
It will not start.

When not using this in the manifest file and using the B4A bridge all works fine, I can debug (Rapid debug works too) and run and all is well. But again when I add the above code to the manifest file it just terminates, nothing in the logs even when unfiltered.

I am using the right icons and have set read only, the display perfectly.

Any ideas?
 

JakeBullet70

Well-Known Member
Licensed User
Longtime User
You have to substitute the capitalized text properly

Here is what I have:

B4X:
AddApplicationText(<activity android:name=".SADLOGICWEATHER" android:label="SADWEATHER">
  <intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
    <category android:name="tv.ouya.intent.category.APP"/>
  </intent-filter>
</activity>)

Is that right?
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
If thats the name of your activity exactly as its written. But id magine your activity name is lower cased, and probably "main"
 

JakeBullet70

Well-Known Member
Licensed User
Longtime User
thanks a bunch!!!!
This is it.
B4X:
AddApplicationText(<activity android:name=".main" android:label="sadLogic Weather">
  <intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
    <category android:name="tv.ouya.intent.category.APP"/>
  </intent-filter>
</activity>)

By the way, do you know if anyone wrapped the native OUYA java libs?

Again, thanks.
 
Top