Vous êtes sur la page 1sur 7

Classes

import java.util.List
A List is a collection which maintains an ordering for its elements. Every element in the List has an index. Each element can thus be accessed by its index, with the first index being zero. Normally, Lists allow duplicate elements, as compared to Sets, where elements have to be unique.

import android.app.Activity

An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI with setContentView(View). While activities are often presented to the user as fullscreen windows, they can also be used in other ways: as floating windows (via a theme with windowIsFloating set) or embedded inside of another activity (using ActivityGroup).

import android.content.BroadcastReceiver
Base class for code that will receive intents sent by sendBroadcast(). If you don't need to send broadcasts across applications, consider using this class with LocalBroadcastManager instead of the more general facilities described below. This will give you a much more efficient implementation (no cross-process communication needed) and allow you to avoid thinking about any security issues related to other applications being able to receive or send your broadcasts.

import android.content.Context;
Interface to global information about an application environment. This is an abstract class whose implementation is provided by the Android system. It allows access to applicationspecific resources and classes, as well as up-calls for application-level operations such as launching activities, broadcasting and receiving intents, etc.

import android.content.IntentFilter;
Structured description of Intent values to be matched. An IntentFilter can match against actions, categories, and data (either via its type, scheme, and/or path) in an Intent. It also includes a "priority" value which is used to order multiple matching filters. IntentFilter objects are often created in XML as part of a package's AndroidManifest.xml file, using intent-filter tags.

import android.net.wifi.WifiConfiguration;

A class representing a configured Wi-Fi network, including the security configuration. Android will not necessarily support all of these security schemes initially.

import android.net.wifi.WifiInfo;
Describes the state of any Wifi connection that is active or is in the process of being set up.

import android.net.wifi.WifiManager;
This class provides the primary API for managing all aspects of Wi-Fi connectivity. Get an instance of this class by callingContext.getSystemService(Context.WIFI_SERVICE). It deals with several categories of items: The list of configured networks. The list can be viewed and updated, and attributes of individual entries can be modified. The currently active Wi-Fi network, if any. Connectivity can be established or torn down, and dynamic information about the state of the network can be queried. Results of access point scans, containing enough information to make decisions about what access point to connect to. It defines the names of various Intent actions that are broadcast upon any sort of change in Wi-Fi state. This is the API to use when performing Wi-Fi specific operations. To perform operations that pertain to network connectivity at an abstract level, use ConnectivityManager.

import android.os.Bundle;
A mapping from String values to various Parcelable types.

import android.util.Log;
API for sending log output. Generally, use the Log.v() Log.d() Log.i() Log.w() and Log.e() methods. The order in terms of verbosity, from least to most is ERROR, WARN, INFO, DEBUG, VERBOSE. Verbose should never be compiled into an application except during development. Debug logs are compiled in but stripped at runtime. Error, warning and info logs are always kept.

import android.view.View;
This class represents the basic building block for user interface components. A View occupies a rectangular area on the screen and is responsible for drawing and event handling. View is the base class for widgets, which are used to create interactive UI components (buttons, text fields, etc.). The ViewGroup subclass is the base class for layouts, which are invisible containers that hold other Views (or other ViewGroups) and define their layout properties.

import android.view.View.OnClickListener;

Interface definition for a callback to be invoked when a view is clicked.

import android.widget.Button;
Represents a push-button widget. Push-buttons can be pressed, or clicked, by the user to perform an action

import android.widget.TextView;
Displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editing; see EditText for a subclass that configures the text view for editing.

import android.widget.Toast;

A toast is a view containing a quick little message for the user. The toast class helps you create and show those. When the view is shown to the user, appears as a floating view over the application. It will never receive focus. The user will probably be in the middle of typing something else. The idea is to be as unobtrusive as possible, while still showing the user the information you want them to see. Two examples are the volume control, and the brief message saying that your settings have been saved. The easiest way to use this class is to call one of the static methods that constructs everything you need and returns a new Toast object.

FUNCTIONS onCreate(Bundle)
Called when the activity is starting. This is where most initialization should go: calling setContentView(int) to inflate the activity's UI, usingfindViewById(int) to programmatically interact with widgets in the UI, calling managedQuery(android.net.Uri, String[], String, String[], String) to retrieve cursors for data being displayed, etc. You can call finish() from within this function, in which case onDestroy() will be immediately called without any of the rest of the activity lifecycle (onStart(), onResume(), onPause(), etc) executing. Derived classes must call through to the super class's implementation of this method. If they do not, an exception will be thrown.

setContentView(View view);
Set the activity content to an explicit view. This view is placed directly into the activity's view hierarchy. It can itself be a complex view hierarchy. When calling this method, the layout parameters of the specified view are ignored. Both the width and the height of the view are set by default to MATCH_PARENT. To use your own layout parameters,

invoke setContentView(android.view.View, android.view.ViewGroup.LayoutParams) instead.

findViewById(R.id.textStatus);
Finds a view that was identified by the id attribute from the XML that was processed in onCreate(Bundle). Returns The view if found or null otherwise.

GetSystemService(String)
Return the handle to a system-level service by name

Context.WIFI_SERVICE
Use with getSystemService(String) to retrieve a WifiManager for handling management of Wi-Fi access.

wifi.getConnectionInfo(); Return dynamic information about the current Wi-Fi connection, if any is active. Returns the Wi-Fi information, contained in WifiInfo.

List<WifiConfiguration> configs = wifi.getConfiguredNetworks();


Return a list of all the networks configured in the supplicant. Not all fields of WifiConfiguration are returned. Only the following fields are filled in: networkId SSID BSSID priority allowedProtocols allowedKeyManagement allowedAuthAlgorithms allowedPairwiseCiphers allowedGroupCiphers Returns a list of network configurations in the form of a list of WifiConfiguration objects.

registerReceiver(receiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));

Register a BroadcastReceiver to be run in the main activity thread. The receiver will be called with any broadcast Intent that matches filter, in the main application thread. The system may broadcast Intents that are "sticky" -- these stay around after the broadcast as finished, to be sent to any later registrations. If your IntentFilter matches one of these sticky Intents, that Intent will be returned by this function and sent to your receiver as if it had just been broadcast. There may be multiple sticky Intents that match filter, in which case each of these will be sent to receiver. In this case, only one of these can be returned directly by the function; which of these that is returned is arbitrarily decided by the system. If you know the Intent your are registering for is sticky, you can supply null for your receiver. In this case, no receiver is registered -- the function simply returns the sticky Intent that matches filter. In the case of multiple matches, the same rules as described above apply.

unregisterReceiver(receiver);
Unregister a previously registered BroadcastReceiver. All filters that have been registered for this BroadcastReceiver will be removed. Parameters

receiver The BroadcastReceiver to unregister.

onClick(View view)
Called when a view has been clicked.

<TOAST> public static final int LENGTH_LONG


Show the view or text notification for a short period of time. This time could be user-definable. This is the default.

Public static Toast makeText (Context context, CharSequence text, int duration)
Make a standard toast that just contains a text view. Parameters context The context to use. Usually your Application or Activity object.

text The text to show. Can be formatted text. duration How long to display the message. Either LENGTH_SHORT or LENGTH_LONG

View.getid()
Returns this view's identifier.

Log.d(String tag, String msg)


Send a DEBUG log message.

public void onReceive(Context c, Intent intent)


This method is called when the BroadcastReceiver is receiving an Intent broadcast. During this time you can use the other methods on BroadcastReceiver to view/modify the current result values. This method is always called within the main thread of its process, unless you explicitly asked for it to be scheduled on a different thread using registerReceiver(BroadcastReceiver, IntentFilter, String, android.os.Handler). When it runs on the main thread you should never perform longrunning operations in it (there is a timeout of 10 seconds that the system allows before considering the receiver to be blocked and a candidate to be killed). You cannot launch a popup dialog in your implementation of onReceive().

wifiManager.disconnect();
Disassociate from the currently active access point. This may result in the asynchronous delivery of state change events.

wifiManager.enableNetwork(bestSignal.describeContents(), true);
Allow a previously configured network to be associated with. If disableOthers is true, then all other configured networks are disabled, and an attempt to connect to the selected network is initiated. This may result in the asynchronous delivery of state change events.

wifiManager.reconnect();
Reconnect to the currently active access point, if we are currently disconnected. This may result in the asynchronous delivery of state change events. Returns true if the operation succeeded

Vous aimerez peut-être aussi