51DegreesTM

51Degrees Java API for Native Google Applications

51Degrees

4/10/2017 9:29 AM

Development

Based off the Find Profiles Tutorial

In this blog post I shall run though how best to use 51Degrees’ Find Profiles API to help best App developers use our Native App data to enhance your device information, and maximise revenue.

With the increase in popularity of Android smart phones, targeted advertising on these devices will help make your marketing more efficient and effective. Using our solution we give you the tools to maximise your revenue on devices by understanding the limits of devices using your product, allowing you to adjust what the end-users see, knowing it will be applicable to them.

Google has released a list of all supported devices which can be found here. Native apps reports model information, using our solution you can take this information and using our API uniquely map it to a specific device.

In the below example I will show you how to use data gathered from a Samsung Galaxy S7 from the Native device data, and expand it using our API to get the full device details you can use.

/* * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. * Copyright © 2015 51Degrees Mobile Experts Limited, 51Degrees, Davidson House, Forbury Square, Reading, Berkshire, RG1 3EU, United Kingdom. * * This Source Code Form is the subject of the following patent * applications, owned by 51Degrees Mobile Experts Limited of 51Degrees Mobile Experts Limited, 51Degrees, Davidson House, Forbury Square, Reading, Berkshire, RG1 3EU, United Kingdom: * European Patent Application No. 13192291.6; and * United States Patent Application Nos. 14/085,223 and 14/085,301. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. * * If a copy of the MPL was not distributed with this file, You can obtain * one at http://mozilla.org/MPL/2.0/. * * This Source Code Form is "Incompatible With Secondary Licenses", as * defined by the Mozilla Public License, v. 2.0. */ package fiftyone. device . example . illustration ; import fiftyone.mobile.detection.Provider; import fiftyone.mobile.detection.entities.Profile; import fiftyone.mobile.detection.entities.Property; import fiftyone.mobile.detection.factories.StreamFactory; import java.io.Closeable; import java.io.IOException; import java.util.List; public class FindProfiles2 implements Closeable { // Snippet Start // Device detection provider which takes User-Agents and returns matches. protected final Provider provider; public String enterpriseDataFile = "[PATH]\\51Degrees-EnterpriseV3_2.dat" ; protected static Property[] hardwareProperties; /** * Initialises the device detection Provider with the declared enterprise data. * For more data see: * <a href="/compare-data-options">compare data options * </a> * [PATH] to be replaced with file path of Enterprise DataFile. * * @throws IOException can be thrown if there is a problem reading from the * provided data file. */ public FindProfiles2() throws IOException { provider = new Provider(StreamFactory. create (enterpriseDataFile, false )); hardwareProperties = provider. dataSet . getComponent ( "HardwarePlatform" ). getProperties (); } /** * Main entry point for this example. * * @param args command line arguments, not used. * @throws java.io.IOException if there is a problem accessing the data file * that will be used for device detection. */ public static void main(String[] args) throws IOException { System. out . println ( "Starting FindProfiles example for the Galaxy S7 using Native Data Samsung|heroqlteacg|SM-G930R7|Galaxy S7." ); FindProfiles2 fp = new FindProfiles2(); try { // Retrieve profiles based on the Native Google search usinf the findProfiles method // Firstly gets a list of all Hardware Profiles that have a NativeBrand = Samsung List<Profile> profiles = fp. provider . dataSet . findProfiles ( "NativeBrand" , "Samsung" , null ); //Next uses the list created to find which of these Devices have the NativeDevice = heroqlteacg //The list is replaced by the new findProfiles method which narrows down the search, this is repeated for the other //two search criteria. profiles = fp. provider . dataSet . findProfiles ( "NativeDevice" , "heroqlteacg" , profiles); profiles = fp. provider . dataSet . findProfiles ( "NativeModel" , "SM-G930R7" , profiles); profiles = fp. provider . dataSet . findProfiles ( "NativeName" , "Galaxy S7" , profiles); //The final profiles list has all profiles that have matched the previous criteria, if you are matching on the //Native Google Key, there should only be 1 profile returned. System. out . println ( "There are " + profiles. size () + " device(s) that match this key" ); //Print all property values for selected profile(s). for (Profile profile : profiles){ System. out . println ( "ProfileId: " + profile. profileId ); for (Property property : hardwareProperties){ System. out . println (property + ": " +profile. getValues (property. getName ())); } System. out . println (); } } finally { fp. close (); } } /** * Closes the {@link fiftyone.mobile.detection.Dataset} by releasing data * file readers and freeing the data file from locks. This method should * only be used when the {@code Dataset} is no longer required, i.e. when * device detection functionality is no longer required, or the data file * needs to be freed. * * @throws IOException if there is a problem accessing the data file. */ @Override public void close() throws IOException { provider. dataSet . close (); } // Snippet End }

From just the 4 fields you can gather from the list of Googles supported devices, you can enhance that information with 51Degrees and get the full device details allowing you to better understand your customers for use in analytics or marketing activities.