Android sdk android launcher

SDK Manager

The Android SDK separates tools, platforms, and other components into packages you can download using the SDK Manager. For example, when the SDK Tools are updated or a new version of the Android platform is released, you can use the SDK Manager to quickly download them to your environment.

You can launch the SDK Manager in one of the following ways:

  • From Eclipse (with ADT), select Window >Android SDK Manager.
  • From Android Studio, select Tools >Android >SDK Manager.
  • On Windows, double-click the SDK Manager.exe file at the root of the Android SDK directory.
  • On Mac or Linux, open a terminal and navigate to the tools/ directory in the location where the Android SDK is installed, then execute android sdk .

You can select which packages you want to download by toggling the checkboxes on the left, then click Install to install the selected packages.

Figure 1. The Android SDK Manager shows the SDK packages that are available, already installed, or for which an update is available.

There are several different packages available for the Android SDK. The table below describes most of the available packages and where they’re located in your SDK directory once you download them.

Here’s an outline of the packages required and those we recommend you use:

SDK Tools Required. Your new SDK installation already has the latest version. Make sure you keep this up to date. SDK Platform-tools Required. You must install this package when you install the SDK for the first time. SDK Platform Required.You must download at least one platform into your environment so you’re able to compile your application. In order to provide the best user experience on the latest devices, we recommend that you use the latest platform version as your build target. You’ll still be able to run your app on older versions, but you must build against the latest version in order to use new features when running on devices with the latest version of Android.

To get started, download the latest Android version, plus the lowest version you plan to support (we recommend Android 2.2 for your lowest version).

System Image Recommended. Although you might have one or more Android-powered devices on which to test your app, it’s unlikely you have a device for every version of Android your app supports. It’s a good practice to download system images for all versions of Android your app supports and test your app running on them with the Android emulator. Android Support Recommended. Includes a static library that allows you to use some of the latest Android APIs (such as fragments, plus others not included in the framework at all) on devices running a platform version as old as Android 1.6. All of the activity templates available when creating a new project with the ADT Plugin require this. For more information, read Support Library. SDK Samples Recommended. The samples give you source code that you can use to learn about Android, load as a project and run, or reuse in your own app. Note that multiple samples packages are available — one for each Android platform version. When you are choosing a samples package to download, select the one whose API Level matches the API Level of the Android platform that you plan to use.

Tip: For easy access to the SDK tools from a command line, add the location of the SDK’s tools/ and platform-tools to your PATH environment variable.

The above list is not comprehensive and you can add new sites to download additional packages from third-parties.

In some cases, an SDK package may require a specific minimum revision of another package or SDK tool. The development tools will notify you with warnings if there is dependency that you need to address. The Android SDK Manager also enforces dependencies by requiring that you download any packages that are needed by those you have selected.

Adding New Sites

By default, Available Packages displays packages available from the Android Repository and Third party Add-ons. You can add other sites that host their own Android SDK add-ons, then download the SDK add-ons from those sites.

Читайте также:  Quick для андроид полная версия

For example, a mobile carrier or device manufacturer might offer additional API libraries that are supported by their own Android-powered devices. In order to develop using their libraries, you must install their Android SDK add-on, if it’s not already available under Third party Add-ons.

If a carrier or device manufacturer has hosted an SDK add-on repository file on their web site, follow these steps to add their site to the Android SDK Manager:

  1. Select Available Packages in the left panel.
  2. Click Add Add-on Site and enter the URL of the repository.xml file. Click OK.

Any SDK packages available from the site will now be listed under a new item named User Add-ons.

Troubleshooting

Problems connecting to the SDK repository

If you are using the Android SDK Manager to download packages and are encountering connection problems, try connecting over http, rather than https. To switch the protocol used by the Android SDK Manager, follow these steps:

Источник

Installing the Android SDK

Android Studio provides everything you need to start developing apps for Android, including the Android Studio IDE and the Android SDK tools.

If you didn’t download Android Studio, go download Android Studio now, or switch to the stand-alone SDK Tools install instructions.

Before you set up Android Studio, be sure you have installed JDK 6 or higher (the JRE alone is not sufficient)—JDK 7 is required when developing for Android 5.0 and higher. To check if you have JDK installed (and which version), open a terminal and type javac -version . If the JDK is not available or the version is lower than 6, go download JDK.

To set up Android Studio on Windows:

  1. Launch the .exe file you just downloaded.
  2. Follow the setup wizard to install Android Studio and any necessary SDK tools.

On some Windows systems, the launcher script does not find where Java is installed. If you encounter this problem, you need to set an environment variable indicating the correct location.

Select Start menu > Computer > System Properties > Advanced System Properties. Then open Advanced tab > Environment Variables and add a new system variable JAVA_HOME that points to your JDK folder, for example C:\Program Files\Java\jdk1.7.0_21 .

The individual tools and other SDK packages are saved outside the Android Studio application directory. If you need to access the tools directly, use a terminal to navigate to the location where they are installed. For example:

To set up Android Studio on Mac OSX:

  1. Unzip the downloaded zip file, android-studio-ide- -mac.zip .
  2. Drag and drop Android Studio into the Applications folder.
  3. Open Android Studio and follow the setup wizard to install any necessary SDK tools.

Depending on your security settings, when you attempt to open Android Studio, you might see a warning that says the package is damaged and should be moved to the trash. If this happens, go to System Preferences > Security & Privacy and under Allow applications downloaded from, select Anywhere. Then open Android Studio again.

  • Follow the links to install the SDK outside of the Android Studio directories.
  • The individual tools and other SDK packages are saved outside the Android Studio application directory. If you need access the tools directly, use a terminal to navigate into the location where they are installed. For example:

    To set up Android Studio on Linux:

    1. Unpack the downloaded Tar file, android-studio-ide- -linux.zip , into an appropriate location for your applications.
    2. To launch Android Studio, navigate to the android-studio/bin/ directory in a terminal and execute studio.sh .

    You may want to add android-studio/bin/ to your PATH environmental variable so that you can start Android Studio from any directory.

    If the SDK is not already installed, follow the setup wizard to install the SDK and any necessary SDK tools.

    Note: You may also need to install the ia32-libs, lib32ncurses5-dev, and lib32stdc++6 packages. These packages are required to support 32-bit apps on a 64-bit machine.

    Android Studio is now ready and loaded with the Android developer tools, but there are still a couple packages you should add to make your Android SDK complete.

    The stand-alone SDK Tools package does not include a complete Android development environment. It includes only the core SDK tools, which you can access from a command line or with a plugin for your favorite IDE (if available).

    If you didn’t download the SDK tools, go download the SDK now, or switch to the Android Studio install instructions.

    To get started on Windows:

    Your download package is an executable file that starts an installer. The installer checks your machine for required tools, such as the proper Java SE Development Kit (JDK) and installs it if necessary. The installer then saves the Android SDK Tools to a specified the location outside of the Android Studio directories.

    1. Double-click the executable ( .exe file) to start the install.
    2. Make a note of the name and location where you save the SDK on your system—you will need to refer to the SDK directory later when using the SDK tools from the command line.
    3. Once the installation completes, the installer starts the Android SDK Manager.

    To get started on Mac OSX:

    Unpack the ZIP file you’ve downloaded. By default, it’s unpacked into a directory named android-sdk-mac_x86 . Move it to an appropriate location on your machine, such as a «Development» directory in your home directory.

    Make a note of the name and location of the SDK directory on your system—you will need to refer to the SDK directory later when using the SDK tools from the command line.

    To get started on Linux:

    Unpack the .zip file you’ve downloaded. The SDK files are download separately to a user-specified directory.

    Make a note of the name and location of the SDK directory on your system—you will need to refer to the SDK directory later when using the SDK tools from the command line.

    Troubleshooting Ubuntu
    • If you need help installing and configuring Java on your development machine, you might find these resources helpful:
      • https://help.ubuntu.com/community/Java
      • https://help.ubuntu.com/community/JavaInstallation
    • Here are the steps to install Java:
      1. If you are running a 64-bit distribution on your development machine, you need to install additional packages first. For Ubuntu 13.10 (Saucy Salamander) and above, install the libncurses5:i386 , libstdc++6:i386 , and zlib1g:i386 packages using apt-get :

        For earlier versions of Ubuntu, install the ia32-libs package using apt-get :

        The Android SDK tools are now ready to begin developing apps, but there are still a couple packages you should add to make your Android SDK complete.

        Then, select which SDK bundle you want to install:

        Источник

        Build a Custom Launcher on Android

        Introduction

        In its most basic form, a launcher is an application that does the following:

        • it represents the home screen of a device
        • it lists and launches applications that are installed on the device

        In other words, it is the application that shows up when you press the home button. Unless you’ve already installed a custom launcher, you are currently using the default launcher that comes with your Android installation. A lot of device manufacturers have their own default, custom launchers that conform to their proprietary look and feel, for example, Samsung TouchWiz and HTC Sense.

        In this tutorial, we are going to create a simple launcher with a basic user interface. It will have two screens:

        • a home screen showing the device’s wallpaper
        • a screen showing the icons and details of the applications installed on the device

        By the way, if you work a lot with Android, you may want to check out one of the 1,000+ Android app templates on Envato Market. There’s a huge variety, so you’re sure to find something there to help you with your work. Or you could outsource areas that aren’t your speciality by hiring an app developer or designer on Envato Studio.

        1. Requirements

        You need to have the following installed and configured on your development machine:

        • Android SDK and platform tools
        • Eclipse IDE 3.7.2 or higher with the ADT plugin
        • an emulator or Android device running Android 2.2 or higher

        You can download the SDK and platform tools the Android developer portal.

        2. Project Setup

        Launch Eclipse and create a new Android application project. I’m naming the application SimpleLauncher, but you can name it anything you want. Make sure you use a unique package. The lowest SDK version our launcher supports is Froyo and the target SDK is Jelly Bean.

        Since we don’t want to create an Activity , deselect Create Activity. Click Finish to continue.

        3. Project Manifest

        The next step is modifying the AndroidManifest.xml file by adding two activities. The first Activity displays the home screen. Let’s name it HomeActivity as shown below.

        By adding the categories android.intent.category.HOME and android.intent.category.DEFAULT to the intent-filter group, the associated Activity behaves like a launcher and shows up as an option when you press the device’s home button.

        We also need to set the launchMode to singleTask to make sure that only one instance of this Activity is held by the system at any time. To show the user’s wallpaper, set the theme to Theme.Wallpaper.NoTitleBar.FullScreen .

        The second Activity we need to add displays the applications that are installed on the user’s device. It’s also responsible for launching applications. We don’t need any special configuration for this Activity . Name it AppsListActivity .

        4. Activity Layouts

        Create an XML file for the HomeActivity class in the project’s res/layout folder and name it activity_home.xml. The layout has a single Button that responds to click events. Clicking the button takes the user from the home screen to the list of applications.

        Next, create an XML file for the AppsListActivity class in the project’s res/layout folder and name it activity_apps_list.xml. The layout contains a ListView that takes up the entire screen.

        Finally, create a third XML file in the same location and name it list_item.xml. This file defines the layout of an item in the ListView . Each list view item represents an application installed on the user’s device. It shows the application’s icon, label, and package name. We display the application icon using an ImageView instance and TextView instances for the label and package name.

        5. Implementing the Activity Classes

        HomeActivity

        With the layouts of the application created, it’s time to create the two Activity classes. When creating the two classes, make sure the name of each class matches the one you specified in the project’s manifest file earlier.

        Create a new class named HomeActivity and set android.app.Activity as its superclass.

        In the class’s onCreate method, we invoke setContentView , passing in the layout we created earlier. You may remember that we added a button to the activity_home layout that triggers a method named showApps . We now need to implement that method in the HomeActivity class. The implementation is pretty simple, we create an Intent for the AppsListActivity class and start it.

        AppsListActivity

        Create another Activity class named AppsListActivity and set android.app.Activity as its superclass. In the class’s onCreate method, we invoke setContentView , passing in the activity_apps_list layout we created earlier.

        Even though our launcher isn’t finished yet, you can save and run your application at this point. When you press the device’s home button, you should see a pop-up asking you which launcher you’d like to use.

        If you choose Simple Launcher Home, you should see your new home screen with a single button in the top right corner of the screen. You should also see your device’s current wallpaper.

        Go back to Eclipse and create a class named AppDetail that will contain the details of an application, its package name, label, and application icon. The interface is pretty basic as you can see below.

        6. Fetching Applications

        In the loadApps method of the AppsListActivity class, we use the queryIntentActivities method of the PackageManager class to fetch all the Intents that have a category of Intent.CATEGORY_LAUNCHER . The query returns a list of the applications that can be launched by a launcher. We loop through the results of the query and add each item to a list named apps . Take a look at the following code snippet for clarification.

        7. Displaying the List of Applications

        With the apps variable containing all the details we need, we can show the list of applications using the ListView class. We create a simple ArrayAdapter and override its getView method to render the list’s items. We then associate the ListView with the adapter.

        8. Listening for Clicks

        When the user clicks an item in the ListView , the corresponding application should be launched by our launcher. We use the getLaunchIntentForPackage method of the PackageManager class to create an Intent with which we start the application. Take a look at the following code snippet.

        9. Putting It All Together

        To make everything work together, we need to invoke loadApps , loadListView , and addClickListener in the onCreate method of the AppsListActivity class as shown below.

        Build and run your application once more to see the result. You should now be able to see the applications that can be launched when you click the button on the home screen of our launcher. Click on an item to launch the corresponding application.

        Conclusion

        You now have your own custom launcher. It’s very basic, but you can add all the customizations you want. If you want to dig deeper into custom launchers, I encourage you to take a look at the sample applications on the Android Developer Portal.

        Источник

        Читайте также:  Андроид разработка яндекс практикум
    Оцените статью