archive-com.com » COM » T » TECHOTOPIA.COM

Total: 1018

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • Working with the Amazon Maps API on the Kindle Fire - Techotopia
    The next step is to register the application in the Amazon distribution portal and input the MD5 debug fingerprint to enable Map support To achieve this open a web browser and navigate to the following URL https developer amazon com welcome html On the welcome page click on the Sign In link in the top right hand corner of the page and enter your login credentials If you do not yet have a developer account click on the Create an Account button to create one now Once logged in click on the Add a New App button located within the dashboard panel as shown in Figure 40 2 Figure 40 2 Within the New App Submission screen enter the mandatory information those fields marked by a red asterisk before clicking on the Save button Once the app has been added select it from the dashboard panel to view the details of the submission Within the application details screen will be a link labeled Maps Click on this link and in the resulting screen click on the Add a Debug Registration button When prompted enter the package name for the application exactly as it appears within the project and then cut and paste the MD5 fingerprint into the Developer Signature field before clicking on the Submit button At this point the development environment is set up to enable Maps to be used within a specific application The next step is to set up the application itself to use maps This begins with making some additions to the application s Android manifest file Adding Map Support to the AndroidManifest xml File Before maps can be used in an application an additional entry needs to be added to the application s Android Manifest file Within Eclipse locate the manifest file for the project for which the Maps JAR file was added to the build path and load the AndroidManifest xml file into the editing panel The line that needs to be added reads as follows xmlns amazon http schemas amazon com apk res android This directive needs to be added as part of the existing manifest element For example xml version 1 0 encoding utf 8 manifest xmlns android http schemas android com apk res android xmlns amazon http schemas amazon com apk res android package com example mapapp android versionCode 1 android versionName 1 0 In addition the Amazon Maps API requires that a number of permissions be requested within the manifest file xml version 1 0 encoding utf 8 manifest xmlns android http schemas android com apk res android xmlns amazon http schemas amazon com apk res android package com example mapapp android versionCode 1 android versionName 1 0 uses permission android name android permission INTERNET uses permission android name android permission ACCESS COARSE LOCATION uses permission android name android permission ACCESS FINE LOCATION Finally the application element of the Manifest file must include the following tag amazon enable feature android name com amazon geo maps android required false For example application android allowBackup true android icon drawable ic launcher android label string app name android theme style AppTheme amazon enable feature android name com amazon geo maps android required false activity android name com example mapapp MapAppActivity android label string app name Enabling Location Based Services on the Kindle Fire Device By default Kindle Fire devices are shipped with location based services disabled Before testing a map based application on a physical device therefore this feature must first be enabled To do this display the settings app on the device via a downward swipe from the top edge of the screen Select the More option followed by Location Based Services Within the location settings screen Figure 40 3 change the Enable location based Services setting from Off to On Figure 40 3 Registering an Emulator When using an AVD Kindle Fire emulator to test maps within an application that emulator must be registered with Amazon An attempt to access maps on an unregistered emulator will result in the application crashing To register an emulator start it running and display the settings app on an emulator this is displayed by clicking at the top of the device display and dragging the mouse to the bottom of the screen Select More followed by My Account On the My Account screen click on the Register button and enter the login and password details associated with your Amazon com account Once the information has been entered click on Register and wait for the process to complete The emulator should now support use of the Amazon Maps API Adjusting the Emulator Location Settings When testing an application in the emulator the location will be set using IP information from the internet connection of the computer system on which the emulator is running Different locations can be simulated using the Debug Perspective within Eclipse This can be displayed by selecting the Window Show Perspective DDMS option When the DDMS perspective appears select the Emulator Control tab in the main panel At the bottom of the panel is a section named Location Controls where new Longitude and Latitude values may be entered Having covered the steps involved in enabling maps support in Kindle Fire applications the remainder of this chapter will provide an overview of how map functionality may be implemented within an application Checking for Map Support All Kindle Fire devices with the exception of the first generation Kindle Fire support the Amazon maps runtime library This means that any application that intends to use the Maps API must check whether the device on which it is running supports the maps feature before attempting to make any Maps API calls The recommended way to perform this task is to check for the presence or otherwise of the maps runtime The following method can be included in applications and subsequently called to check whether maps are supported public boolean hasMapSupport boolean result false try Class forName com amazon geo maps MapView result true catch Exception e return

    Original URL path: http://www.techotopia.com/index.php/Working_with_the_Amazon_Maps_API_on_the_Kindle_Fire (2016-02-13)
    Open archived version from archive


  • A Kindle Fire Amazon Maps API Tutorial - Techotopia
    for the MyMapView activity to be discoverable by the intent resolution system it will need to be declared within the application s manifest Edit the AndroidManifest xml file for the application once again and modify it to add this declaration xml version 1 0 encoding utf 8 manifest xmlns android http schemas android com apk res android xmlns amazon http schemas amazon com apk res android package com example mapexample android versionCode 1 android versionName 1 0 uses permission android name android permission INTERNET uses permission android name android permission ACCESS COARSE LOCATION uses permission android name android permission ACCESS FINE LOCATION uses sdk android minSdkVersion 8 android targetSdkVersion 16 application android allowBackup true android icon drawable ic launcher android label string app name android theme style AppTheme amazon enable feature android name com amazon geo maps android required false activity android name com example mapexample MapExampleActivity android label string app name intent filter action android name android intent action MAIN category android name android intent category LAUNCHER intent filter activity activity android name MyMapView android label MyMapView activity application manifest Adding the MapView Object With the class and layout created for displaying the map view to the user the next logical step is to add the MapView instance to the layout file Locate the res layout my map view layout xml file within the Package Explorer panel and double click on it to load it into the editing panel Select the my map view layout xml tab beneath the Graphical Layout tool to display the XML and add a MapView instance so that the XML reads as follows xml version 1 0 encoding utf 8 RelativeLayout xmlns android http schemas android com apk res android android layout width match parent android layout height match parent com amazon geo maps MapView android id id mapview android layout width fill parent android layout height fill parent android clickable true android enabled true RelativeLayout Once the map view has been added save the XML file and then load the MyMapView java file into the editing panel Add an onCreate method to this class to inflate the user interface layout when the activity is launched package com example mapexample import android os Bundle import com amazon geo maps MapActivity public class MyMapView extends MapActivity public void onCreate Bundle savedInstanceState super onCreate savedInstanceState setContentView R layout my map view layout Override protected boolean isRouteDisplayed TODO Auto generated method stub return false Designing the User Interface for the MapExampleActivity Class Locate and double click on the res layout activity map example xml file and using the Graphical Layout tool delete the default Hello world TextView object With a clean user interface layout drag and drop a Button view onto the layout canvas and position it so that it is centered both horizontally and vertically within the parent layout manager view Change the text on the button to read Find Location With the button positioned drag and drop an Address EditText view so that it is

    Original URL path: http://www.techotopia.com/index.php/A_Kindle_Fire_Amazon_Maps_API_Tutorial (2016-02-13)
    Open archived version from archive

  • Marking Android Map Locations using Amazon Map Overlays - Techotopia
    MyMapOverlay extends ItemizedOverlay Item Now a set of mandatory methods needs to be added to the class to implement the overlay behavior package com example mapexample import java util ArrayList import android app AlertDialog import android content Context import android graphics drawable Drawable import com amazon geo maps ItemizedOverlay import com amazon geo maps OverlayItem public class MyMapOverlay extends ItemizedOverlay OverlayItem private ArrayList OverlayItem mOverlays new ArrayList OverlayItem Context mContext public MyMapOverlay Drawable marker super boundCenterBottom marker public MyMapOverlay Drawable marker Context context super boundCenterBottom marker mContext context public void addOverlay OverlayItem overlay mOverlays add overlay populate Override protected OverlayItem createItem int i return mOverlays get i Override public int size return mOverlays size Override protected boolean onTap int i OverlayItem item mOverlays get i AlertDialog Builder dialog new AlertDialog Builder mContext dialog setTitle item getTitle dialog setMessage item getSnippet dialog show return true These are largely standard implementations of these methods that can be used for most map overlays They serve to ensure that items added to the overlay are handled correctly that instances of the overlay can be created and passed an image to act as the marker and to display an alert dialog containing additional information when a marker is tapped by the user Adding the Drawable to the Project When the overlay implementation is complete and the application runs an image will appear at the location corresponding to the address entered by the user Before this can happen however the image needs to be added to the project resources The image used in this tutorial may be downloaded from the following URL http www ebookfrenzy com android book marker png Once downloaded return to Eclipse and unfold the res section of the project in the Package Explorer panel Drag and drop the marker png file onto the drawable hdpi folder as shown in Figure 42 1 Figure 42 1 Adding the Overlay to the MapView All that remains is to add some code to the MyMapView class to implement the overlay Edit the MyMapView java class file and modify the onCreate method as follows package com example mapexample import java util List import android location Address import android os Bundle import com amazon geo maps GeoPoint import com amazon geo maps MapActivity import com amazon geo maps MapController import com amazon geo maps MapView import com amazon geo maps Overlay import com amazon geo maps OverlayItem import android graphics drawable Drawable public class MyMapView extends MapActivity private static MapController mMapController private static MapView mMapView public void onCreate Bundle savedInstanceState super onCreate savedInstanceState setContentView R layout my map view layout mMapView MapView findViewById R id mapview mMapView setBuiltInZoomControls true mMapController mMapView getController Bundle extras getIntent getExtras if extras null return Address address Address extras get address GeoPoint newLocation new GeoPoint int address getLatitude 1E6 int address getLongitude 1E6 List Overlay mapOverlays mMapView getOverlays Drawable drawable this getResources getDrawable R drawable marker MyMapOverlay newOverlay new MyMapOverlay drawable this OverlayItem overlayItem new OverlayItem newLocation address getAddressLine 0 address getAddressLine

    Original URL path: http://www.techotopia.com/index.php/Marking_Android_Map_Locations_using_Amazon_Map_Overlays (2016-02-13)
    Open archived version from archive

  • An Overview of the Amazon In-App Purchasing API - Techotopia
    call this method in the onResume method of the activity to ensure that the current user did not change while the application was suspended Once completed this method triggers a call to the onGetUserIdResponse method of the registered observer initiateItemDataRequest Returns data about the specified list of products referenced by SKU codes Once completed this method triggers a call to the onItemDataResponse method of the registered observer initiatePurchaseUpdatesRequest Requests the status of all previous purchases made by the user This method is of particular importance when an application needs to synchronize entitled content across multiple devices Once completed this method triggers a call to the onPurchaseUpdatesResponse method of the registered observer initiatePurchaseRequest Initiates the purchase of the item specified by the referenced SKU code Once completed this method triggers a call to the onPurchaseResponse method of the registered observer The Amazon Client The Amazon Client is a service on the device that is activated when an application initiates a purchase using the Amazon In App API This client is responsible for all interaction with the user during the purchasing process including presenting a user interface through which the purchase will be performed Figure 43 1 for example illustrates the user interface of the client during the purchase of virtual treasure within a game Figure 43 1 The client operates entirely independently of the application and handles all aspects of the process including presenting errors to the user in the event that the purchase cannot be completed for example due to an expired or invalid credit card number Once the purchase is complete the application will be notified via the registered observer and must assuming a successful outcome act accordingly to provide access to the purchased content or feature Since the user will have already been notified by the client of an unsuccessful purchase it is not necessary for the application itself to report this to the user The SDK Tester It goes without saying that it would quickly become expensive if you had to make real purchases each time you wanted to test the in app purchasing features of an application In fact only applications that have been approved by Amazon and published through the Amazon Mobile App Distribution portal are able to make real in app purchases Applications that have not yet been published can instead be used with the SDK Tester tool This application can be installed on either a physical Kindle Fire device or an emulator and used to simulate the in app purchasing process If an application that has not yet been published attempts to make an in app purchase the system will divert the requests to the SDK Tester tool instead of to the Amazon Client When the SDK Tester tool is installed a JSON data file containing information about the products available for purchase must also be uploaded to the SD Card storage of the device The tester tool also has a range of configuration options that can be used to simulate a variety

    Original URL path: http://www.techotopia.com/index.php/An_Overview_of_the_Amazon_In-App_Purchasing_API (2016-02-13)
    Open archived version from archive

  • A Simple Amazon In-App Purchasing Example Application - Techotopia
    com amazon inapp purchasing PurchaseResponse import com amazon inapp purchasing PurchaseUpdatesResponse import com amazon inapp purchasing PurchasingObserver public class InAppObserver extends PurchasingObserver private final InAppDemoActivity baseActivity public InAppObserver final InAppDemoActivity buyerActivity super buyerActivity this baseActivity buyerActivity Override public void onGetUserIdResponse GetUserIdResponse arg0 TODO Auto generated method stub Save the changes to the file before proceeding Having created a PurchasingObserver subclass the next step is to make sure that it is registered with the application s PurchasingManager instance To achieve this edit the InAppDemoActivity java class and add an onStart lifecycle method as follows note also that the onResume method has been added to ensure that changes in user are detected package com example inappdemo import com amazon inapp purchasing PurchasingManager import android os Bundle import android app Activity import android view Menu public class InAppDemoActivity extends Activity Override protected void onCreate Bundle savedInstanceState super onCreate savedInstanceState setContentView R layout activity in app demo Override public void onStart super onStart InAppObserver observer new InAppObserver this PurchasingManager registerObserver observer Override protected void onResume super onResume PurchasingManager initiateGetUserIdRequest Override public boolean onCreateOptionsMenu Menu menu getMenuInflater inflate R menu activity in app demo menu return true Adding the SKU as a String Resource Later in this chapter the product item declaration will be declared in a JSON data file and uploaded to the device or emulator in which the application is being tested In app purchase items are identified by a SKU code which will need to be part of the item definition The SKU code will also be used when requesting information and initiating the item purchase For the purposes of this tutorial we will be using the following SKU code and storing it as a string resource com example inappdemo fireworks To add the SKU code as a string resource navigate in the Package Explorer to the res values folder and double click on the strings xml file to load it into the editor Select the strings xml tab along the bottom edge of the Android Resources panel to edit the XML definition directly Add a new line to the XML so that the file reads as follows xml version 1 0 encoding utf 8 resources string name app name InAppDemo string string name hello world Hello world string string name menu settings Settings string string name purchase string Purchase Image string string name consumable sku com example inappdemo fireworks string resources Once the resource has been added save and close the file Displaying the Purchase Item Details When the user interface for the application was designed three TextView objects were included to display the title description and price of the item to the user Generally an application should always obtain this information using the purchasing API rather than hard coding the information into the application This ensures that the information always matches what is set up in the distribution portal and allows the information to be changed without having to modify the application The standard mechanism for obtaining product information is to call the initiateItemDataRequest method of the Purchasing Manager passing through a set of SKUs for the items for which data is required This in turn will result in a call to the onItemDataResponse method of the registered observer instance which will be passed an ItemDataResponse object containing the requested data In the first instance the onStart method in the InAppDemoActivity java file needs to be modified to create a Java Set including the SKU of our product and then call the initiateItemDataRequest method of the Purchasing Manager package com example inappdemo import java util HashSet import java util Set import com amazon inapp purchasing PurchasingManager import android os Bundle import android app Activity import android view Menu import android widget TextView public class InAppDemoActivity extends Activity Override public void onStart super onStart InAppObserver observer new InAppObserver this PurchasingManager registerObserver observer Set String skuList new HashSet String 1 skuList add getResources getString R string consumable sku PurchasingManager initiateItemDataRequest skuList When the observer receives the product item data it is going to call a method of the InAppActivityDemo class the purpose of which is to update the user interface with information about the item We will name this method displayItem and implement it in the InAppDemoActivity java file as follows package com example inappdemo import java util HashSet import java util Set import com amazon inapp purchasing Item import com amazon inapp purchasing PurchasingManager import android os Bundle import android app Activity import android view Menu import android widget TextView import android view View import android widget ImageView public class InAppDemoActivity extends Activity public void displayItem Item item TextView titleText TextView findViewById R id titleText TextView descriptionText TextView findViewById R id descriptionText TextView priceText TextView findViewById R id priceText titleText setText Item item getTitle descriptionText setText Desc item getDescription priceText setText Price item getPrice This method will be passed an Item object containing information relating to the specified SKU All that it then does is obtain references to the TextView objects before displaying the corresponding data on each view The next task is to implement the onItemDataResponse method in the observer class Select the InAppObserver java file therefore and modify this method so that it reads as follows package com example inappdemo import java util Map import com amazon inapp purchasing GetUserIdResponse import com amazon inapp purchasing Item import android app AlertDialog import com amazon inapp purchasing ItemDataResponse import com amazon inapp purchasing PurchaseResponse import com amazon inapp purchasing PurchaseUpdatesResponse import com amazon inapp purchasing PurchasingObserver public class InAppObserver extends PurchasingObserver Override public void onItemDataResponse ItemDataResponse itemDataResponse switch itemDataResponse getItemDataRequestStatus case SUCCESSFUL final Map String Item items itemDataResponse getItemData for final String key items keySet Item i items get key baseActivity displayItem i break case SUCCESSFUL WITH UNAVAILABLE SKUS Handle Unavailable SKUs break case FAILED Handle failure break The first action performed by this method is to get the status information from the response If the request was successful the code works through the map of items returned since we specified

    Original URL path: http://www.techotopia.com/index.php/A_Simple_Amazon_In-App_Purchasing_Example_Application (2016-02-13)
    Open archived version from archive

  • Integrating Ads with the Amazon Mobile Ads API - Techotopia
    path lib From within the lib directory select the amazon ads ver jar file At time of writing this file is named amazon ads 4 0 9 jar but may have been superseded since then by a newer version Once selected click on the Open button to add the JAR file to the project Once added it should be listed in the Java Build Path panel Assuming the JAR file is now listed click on OK to close the Properties dialog Finally the JAR file needs to be added to the libs folder of the project Within an operating system file browser window locate the JAR file and drag and drop it onto the libs folder of the project in the Package Explorer panel When prompted whether to copy or link the library select the copy option Obtaining the Application Key Part of the process of displaying ads in an application involves registering the application s key with the API Each application added to the Amazon Mobile App Distribution portal is assigned a unique application key Once an application has been registered select it from the My Apps page on the portal and locate the key which will be listed on the General Information page Configuring the Manifest File The Amazon Ads API requires that a number of permissions be requested within the application s manifest file At a minimum the application must request permission for internet access For full functionality however the application should also request network state Wi Fi state and location permissions as follows uses permission android name android permission INTERNET uses permission android name android permission ACCESS COARSE LOCATION uses permission android name android permission ACCESS FINE LOCATION uses permission android name android permission ACCESS NETWORK STATE uses permission android name android permission ACCESS WIFI STATE In addition the API also requires that the MraidBrowser and VideoActionHandler actions be declared within the application element of the manifest file These are required to enable rich media content to be displayed from within the application activity android name com amazon device ads MraidBrowser android configChanges keyboardHidden orientation activity android name com amazon device ads VideoActionHandler android configChanges keyboardHidden orientation screenSize Adding the Amazon Ad Resources Ads may be added to an application either via code within an activity or by adding ad views to the XML layout resources of the user interface In the latter case an additional resource file must be added to the project This file is named amazon ads attrs xml and is located in the res values folder of the location into which the Amazon Mobile Ads API was previously installed In order to include ad views in layout resource files this file must be added to the res values folder of the project This can be achieved by locating the file in a file system browser window and dragging and dropping it onto the project s res values folder in the Eclipse Package Explorer panel so that it appears as illustrated in Figure 45 1 Figure 45 1 Once these steps have been taken the project is ready to begin implementing ads starting with registering the application key with the API Registering the Application Key Preceding sections of this chapter outlined the steps to identify the application key for an application Once this has been obtained it must be registered within the application code before ads can be displayed This needs to be performed once per application launch so is best performed in the onCreate method of the application s main activity For example Override protected void onCreate Bundle savedInstanceState super onCreate savedInstanceState setContentView R layout activity ad example AdRegistration setAppKey getApplicationContext abcdefabcdefabcdefabcdefabcdefa Writing Java Code to Display an Ad The AdLayout view class is used to display ads within an application user interface As previously outlined ads may be incorporated into the user interface of an application either by writing code or via an activity s XML layout file When writing code a new instance of the AdLayout class must be created specifying the size of ad required This AdLayout instance is then added to the user interface and its loadAd method called to load the ad into the view The following code fragment for example creates a new 600x90 AdLayout instance adds it to a layout manager view and then loads the ad AdLayout myAdView myAdView new AdLayout this AdLayout AdSize AD SIZE 600x90 LinearLayout layout LinearLayout findViewById R id LinearLayout1 LinearLayout LayoutParams params new LinearLayout LayoutParams LinearLayout LayoutParams WRAP CONTENT LinearLayout LayoutParams WRAP CONTENT layout addView myAdView params AdTargetingOptions adOptions new AdTargetingOptions myAdView loadAd adOptions Adding an Ad to the Layout Resource File An alternative to writing code is to include the ad in the XML layout resource file This involves loading the Amazon namespace into the XML file and adding an AdLayout element to the design The following XML for example shows a LinearLayout manager containing a single 600x90 ad view LinearLayout xmlns android http schemas android com apk res android xmlns Amazon http schemas android com apk res com example adexample xmlns tools http schemas android com tools android id id LinearLayout1 android layout width match parent android layout height match parent android orientation vertical tools context AdExampleActivity com amazon device ads AdLayout android id id myAdView android layout width 600dp android layout height 90dp Amazon adSize 600x90 LinearLayout Adding the AdLayout view in the XML layout file does not entirely negate the need to write code In order for the ad to appear it is still necessary to make a call to the loadAd method of the AdLayout view when the activity starts up for example AdLayout myAdView AdLayout findViewById R id myAdView AdTargetingOptions adOptions new AdTargetingOptions myAdView loadAd adOptions Setting Ad Targeting Options Ad targeting options are specified by creating an appropriately configured AdTargetingOptions object and passing it through as an argument to the loadAd method of the AdLayout view In the preceding code examples an empty AdTargetingOptions object was created essentially indicating that no ad

    Original URL path: http://www.techotopia.com/index.php/Integrating_Ads_with_the_Amazon_Mobile_Ads_API (2016-02-13)
    Open archived version from archive

  • A Kindle Fire Amazon Mobile Ads API Example Application - Techotopia
    to the XML view Within this file add the appropriate permission and activity tags so that the file reads as follows xml version 1 0 encoding utf 8 manifest xmlns android http schemas android com apk res android package com example adexample android versionCode 1 android versionName 1 0 uses permission android name android permission INTERNET uses permission android name android permission ACCESS COARSE LOCATION uses permission android name android permission ACCESS FINE LOCATION uses permission android name android permission ACCESS NETWORK STATE uses permission android name android permission ACCESS WIFI STATE uses sdk android minSdkVersion 8 android targetSdkVersion 17 application android allowBackup true android icon drawable ic launcher android label string app name android theme style AppTheme activity android name com example adexample AdExampleActivity android label string app name intent filter action android name android intent action MAIN category android name android intent category LAUNCHER intent filter activity activity android name com amazon device ads MraidBrowser android configChanges keyboardHidden orientation activity android name com amazon device ads VideoActionHandler android configChanges keyboardHidden orientation screenSize application manifest Modifying the User Interface Layout For the purposes of this example the ad will be created and displayed in the code of the activity rather than via the layout XML file Before writing the Java code to achieve this however some slight changes need to be made to the activity ad example xml file Locate this file in the Package Explorer panel and double click on it to load it into the Graphical Layout tool Once it has loaded select and delete the Hello World TextView object Next right click on the layout background select the Change Layout menu option and use the resulting dialog to change the layout type to LinearLayout Vertical Implementing the AdListener In order to receive event notifications from the AdLayout view it is necessary to declare a listener class In order to make the AdExampleActivity class act as the listener for this application locate and edit the AdExampleActivity java file and modify it as follows package com example adexample import com amazon device ads AdError import com amazon device ads AdLayout import com amazon device ads AdListener import com amazon device ads AdProperties import android os Bundle import android app Activity import android util Log import android view Menu public class AdExampleActivity extends Activity implements AdListener private static final String TAG com example adexample Override protected void onCreate Bundle savedInstanceState AdLayout myAdView super onCreate savedInstanceState setContentView R layout activity ad example Override public boolean onCreateOptionsMenu Menu menu getMenuInflater inflate R menu activity ad example menu return true Override public void onAdCollapsed AdLayout adLayout Log i TAG Ad collapsed Override public void onAdExpanded AdLayout adLayout Log i TAG Ad expanded Override public void onAdFailedToLoad AdLayout adLayout AdError adError Log i TAG Ad failed to load Override public void onAdLoaded AdLayout adLayout AdProperties adProperties Log i TAG Ad loaded successfully Modifying the onCreate Method The remainder of the work to display the ad is going to be performed within the onCreate

    Original URL path: http://www.techotopia.com/index.php/A_Kindle_Fire_Amazon_Mobile_Ads_API_Example_Application (2016-02-13)
    Open archived version from archive

  • Handling Different Kindle Fire Devices and Displays - Techotopia
    value of a display indicates the minimum width of that display measured in dp units The smallest width values for the Kindle Fire family of devices are as follows Kindle Fire 2nd Generation sw600dp Kindle Fire HD 7 sw533dp Kindle Fire HD 8 9 sw800dp Notable by its absence from the above list is the first generation Kindle Fire This is because the concept of smallest width was not introduced into Android until version 3 2 As such this value is not available for the first generation Kindle Fire This however can be resolved by allocating the default layout to the first generation Kindle Fire and setting specific layouts for those devices that support the smallest width qualifier Display specific layouts are implemented by creating additional sub directories under the res directory of a project The naming convention for these folders is layout smallest width For example layout resource folders for the entire family of Kindle Fire devices would be required as follows res layout Kindle Fire first generation res layout sw600dp Kindle Fire second generation res layout sw533dp Kindle Fire HD 7 res layout sw800dp Kindle Fire HD 8 9 Each folder must in turn contain a copy of the layout XML file adapted for the corresponding display all of which must have matching file names Once implemented the Android runtime system will automatically select the correct layout file to display to the user to match the device display Providing Different Images User interface layouts are not the only area of concern when adapting an application for different screen densities dimensions and aspect ratios Another area to pay attention to is that of images An image that appears correctly scaled on an HD 8 9 screen for example might not appear correctly scaled on a first generation Kindle Fire device As with layouts however multiple sets of images can be bundled with the application each tailored for a specific display This can once again be achieved by referencing the smallest width value In this case drawable folders need to be created in the res directory For example res drawable Kindle Fire first generation res drawable sw600dp Kindle Fire second generation res drawable sw533dp Kindle Fire HD 7 res drawable sw800dp Kindle Fire HD 8 9 Having created the folders simply place the display specific versions of the images into the corresponding folder using the same name for each of the images Alternatively the images may be categorized into broader display densities using the following directories res drawable mdpi First and second generation Kindle Fire devices res drawable hdpi Kindle Fire HD 7 and Kindle Fire HD 8 9 Checking for Hardware Support By now it should be apparent that not all Kindle Fire models were created equal By far the weakest links in the chain are the first and second generation Kindle Fires no camera or microphone An application that makes use of these hardware features should include code to gracefully handle the absence of specific hardware on older

    Original URL path: http://www.techotopia.com/index.php/Handling_Different_Kindle_Fire_Devices_and_Displays (2016-02-13)
    Open archived version from archive