question

GARTH O SMITH avatar image
GARTH O SMITH asked

[UNITY] Separate Android/Kindle builds? Or same build?

Hello! I'm sure this has been asked many times but I wasn't able to find any suggestions. I'm porting an Unity Android app to the Kindle Fire. We plan on using Amazon's IAP and Game Circle on the Kindle, and Google's services on non-Kindles. Is there some code I can use to determine if our app is running on a Kindle or not? Or do you guys use compiler directives and make separate Android and Kindle builds? Thanks for your help. - Garth
fire tablet
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Garth, You should look for android.os.Build.MODEL in runtime to know what device you are running on. The values you are going to receive for android.os.Build.MODEL for all Kindle devices are documented here : https://developer.amazon.com/public/solutions/devices/kindle-fire/specifications/01-device-and-feature-specifications#Device%20Specifications
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

j2Coffee avatar image
j2Coffee answered
You may want to look into the SystemInfo.deviceModel within Unity. If that string starts with 'Amazon' that should allow you to load the correct IAP and games libraries.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

loloiolol avatar image
loloiolol answered
Same problems here!
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi loloiolol, Is SystemInfo.deviceModel not giving the right information to you? If yes, please mention the device name and unity version of your app.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

alex-b avatar image
alex-b answered
I'd like to implement Game Circle for any device (including non-Kindle devices) when app is downloaded from Amazon store, and use google services otherwise. Is there a way to check which store the app was downloaded from? (Also using Unity)
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

DougM@Amazon avatar image
DougM@Amazon answered
Hello Alex, This isn't possible in Unity without invoking the JNI bridge. So, because of this, this is computationally expensive to do so. With that warning said, it would be done using the following calls: #if UNITY_ANDROID AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaClass unityPlayerActivity = up.GetStatic ("currentActivity"); AndroidJavaObject packageManager = unityPlayerActivty.Call ("getPackageManager"); String store = packageManager.call("getInstallerPackageManager","com.package.name"); if(store.StartsWith("com.amazon")){ //use GameCircle here } Where com.package.name would be replaced with the package name/bundle identifier that you either define in the Assets->Plugins->Android->AndroidManifest.xml file or in Player settings.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.