* commit '08e91352169457ac86a2465e4db867971ce14b10': docs: fix misc bugs from external tracker
This commit is contained in:
@@ -34,8 +34,8 @@ import java.lang.reflect.Constructor;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used to instantiate layout XML file into its corresponding View
|
* Instantiates a layout XML file into its corresponding {@link android.view.View}
|
||||||
* objects. It is never be used directly -- use
|
* objects. It is never used directly. Instead, use
|
||||||
* {@link android.app.Activity#getLayoutInflater()} or
|
* {@link android.app.Activity#getLayoutInflater()} or
|
||||||
* {@link Context#getSystemService} to retrieve a standard LayoutInflater instance
|
* {@link Context#getSystemService} to retrieve a standard LayoutInflater instance
|
||||||
* that is already hooked up to the current context and correctly configured
|
* that is already hooked up to the current context and correctly configured
|
||||||
|
|||||||
@@ -1183,7 +1183,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
/**
|
/**
|
||||||
* Equivalent to calling ImageView.setImageBitmap
|
* Equivalent to calling ImageView.setImageBitmap
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose drawable should change
|
* @param viewId The id of the view whose bitmap should change
|
||||||
* @param bitmap The new Bitmap for the drawable
|
* @param bitmap The new Bitmap for the drawable
|
||||||
*/
|
*/
|
||||||
public void setImageViewBitmap(int viewId, Bitmap bitmap) {
|
public void setImageViewBitmap(int viewId, Bitmap bitmap) {
|
||||||
@@ -1206,7 +1206,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
* and {@link Chronometer#start Chronometer.start()} or
|
* and {@link Chronometer#start Chronometer.start()} or
|
||||||
* {@link Chronometer#stop Chronometer.stop()}.
|
* {@link Chronometer#stop Chronometer.stop()}.
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the {@link Chronometer} to change
|
||||||
* @param base The time at which the timer would have read 0:00. This
|
* @param base The time at which the timer would have read 0:00. This
|
||||||
* time should be based off of
|
* time should be based off of
|
||||||
* {@link android.os.SystemClock#elapsedRealtime SystemClock.elapsedRealtime()}.
|
* {@link android.os.SystemClock#elapsedRealtime SystemClock.elapsedRealtime()}.
|
||||||
@@ -1227,7 +1227,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
*
|
*
|
||||||
* If indeterminate is true, then the values for max and progress are ignored.
|
* If indeterminate is true, then the values for max and progress are ignored.
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the {@link ProgressBar} to change
|
||||||
* @param max The 100% value for the progress bar
|
* @param max The 100% value for the progress bar
|
||||||
* @param progress The current value of the progress bar.
|
* @param progress The current value of the progress bar.
|
||||||
* @param indeterminate True if the progress bar is indeterminate,
|
* @param indeterminate True if the progress bar is indeterminate,
|
||||||
@@ -1333,7 +1333,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
/**
|
/**
|
||||||
* Equivalent to calling {@link android.widget.TextView#setTextColor(int)}.
|
* Equivalent to calling {@link android.widget.TextView#setTextColor(int)}.
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the view whose text color should change
|
||||||
* @param color Sets the text color for all the states (normal, selected,
|
* @param color Sets the text color for all the states (normal, selected,
|
||||||
* focused) to be this color.
|
* focused) to be this color.
|
||||||
*/
|
*/
|
||||||
@@ -1346,7 +1346,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
*
|
*
|
||||||
* @param appWidgetId The id of the app widget which contains the specified view. (This
|
* @param appWidgetId The id of the app widget which contains the specified view. (This
|
||||||
* parameter is ignored in this deprecated method)
|
* parameter is ignored in this deprecated method)
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the {@link AbsListView}
|
||||||
* @param intent The intent of the service which will be
|
* @param intent The intent of the service which will be
|
||||||
* providing data to the RemoteViewsAdapter
|
* providing data to the RemoteViewsAdapter
|
||||||
* @deprecated This method has been deprecated. See
|
* @deprecated This method has been deprecated. See
|
||||||
@@ -1361,7 +1361,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
* Equivalent to calling {@link android.widget.AbsListView#setRemoteViewsAdapter(Intent)}.
|
* Equivalent to calling {@link android.widget.AbsListView#setRemoteViewsAdapter(Intent)}.
|
||||||
* Can only be used for App Widgets.
|
* Can only be used for App Widgets.
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the {@link AbsListView}
|
||||||
* @param intent The intent of the service which will be
|
* @param intent The intent of the service which will be
|
||||||
* providing data to the RemoteViewsAdapter
|
* providing data to the RemoteViewsAdapter
|
||||||
*/
|
*/
|
||||||
@@ -1372,7 +1372,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
/**
|
/**
|
||||||
* Equivalent to calling {@link android.widget.AbsListView#smoothScrollToPosition(int, int)}.
|
* Equivalent to calling {@link android.widget.AbsListView#smoothScrollToPosition(int, int)}.
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the view to change
|
||||||
* @param position Scroll to this adapter position
|
* @param position Scroll to this adapter position
|
||||||
*/
|
*/
|
||||||
public void setScrollPosition(int viewId, int position) {
|
public void setScrollPosition(int viewId, int position) {
|
||||||
@@ -1382,7 +1382,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
/**
|
/**
|
||||||
* Equivalent to calling {@link android.widget.AbsListView#smoothScrollToPosition(int, int)}.
|
* Equivalent to calling {@link android.widget.AbsListView#smoothScrollToPosition(int, int)}.
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the view to change
|
||||||
* @param offset Scroll by this adapter position offset
|
* @param offset Scroll by this adapter position offset
|
||||||
*/
|
*/
|
||||||
public void setRelativeScrollPosition(int viewId, int offset) {
|
public void setRelativeScrollPosition(int viewId, int offset) {
|
||||||
@@ -1392,7 +1392,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
/**
|
/**
|
||||||
* Call a method taking one boolean on a view in the layout for this RemoteViews.
|
* Call a method taking one boolean on a view in the layout for this RemoteViews.
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the view on which to call the method.
|
||||||
* @param methodName The name of the method to call.
|
* @param methodName The name of the method to call.
|
||||||
* @param value The value to pass to the method.
|
* @param value The value to pass to the method.
|
||||||
*/
|
*/
|
||||||
@@ -1403,7 +1403,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
/**
|
/**
|
||||||
* Call a method taking one byte on a view in the layout for this RemoteViews.
|
* Call a method taking one byte on a view in the layout for this RemoteViews.
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the view on which to call the method.
|
||||||
* @param methodName The name of the method to call.
|
* @param methodName The name of the method to call.
|
||||||
* @param value The value to pass to the method.
|
* @param value The value to pass to the method.
|
||||||
*/
|
*/
|
||||||
@@ -1414,7 +1414,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
/**
|
/**
|
||||||
* Call a method taking one short on a view in the layout for this RemoteViews.
|
* Call a method taking one short on a view in the layout for this RemoteViews.
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the view on which to call the method.
|
||||||
* @param methodName The name of the method to call.
|
* @param methodName The name of the method to call.
|
||||||
* @param value The value to pass to the method.
|
* @param value The value to pass to the method.
|
||||||
*/
|
*/
|
||||||
@@ -1425,7 +1425,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
/**
|
/**
|
||||||
* Call a method taking one int on a view in the layout for this RemoteViews.
|
* Call a method taking one int on a view in the layout for this RemoteViews.
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the view on which to call the method.
|
||||||
* @param methodName The name of the method to call.
|
* @param methodName The name of the method to call.
|
||||||
* @param value The value to pass to the method.
|
* @param value The value to pass to the method.
|
||||||
*/
|
*/
|
||||||
@@ -1436,7 +1436,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
/**
|
/**
|
||||||
* Call a method taking one long on a view in the layout for this RemoteViews.
|
* Call a method taking one long on a view in the layout for this RemoteViews.
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the view on which to call the method.
|
||||||
* @param methodName The name of the method to call.
|
* @param methodName The name of the method to call.
|
||||||
* @param value The value to pass to the method.
|
* @param value The value to pass to the method.
|
||||||
*/
|
*/
|
||||||
@@ -1447,7 +1447,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
/**
|
/**
|
||||||
* Call a method taking one float on a view in the layout for this RemoteViews.
|
* Call a method taking one float on a view in the layout for this RemoteViews.
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the view on which to call the method.
|
||||||
* @param methodName The name of the method to call.
|
* @param methodName The name of the method to call.
|
||||||
* @param value The value to pass to the method.
|
* @param value The value to pass to the method.
|
||||||
*/
|
*/
|
||||||
@@ -1458,7 +1458,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
/**
|
/**
|
||||||
* Call a method taking one double on a view in the layout for this RemoteViews.
|
* Call a method taking one double on a view in the layout for this RemoteViews.
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the view on which to call the method.
|
||||||
* @param methodName The name of the method to call.
|
* @param methodName The name of the method to call.
|
||||||
* @param value The value to pass to the method.
|
* @param value The value to pass to the method.
|
||||||
*/
|
*/
|
||||||
@@ -1469,7 +1469,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
/**
|
/**
|
||||||
* Call a method taking one char on a view in the layout for this RemoteViews.
|
* Call a method taking one char on a view in the layout for this RemoteViews.
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the view on which to call the method.
|
||||||
* @param methodName The name of the method to call.
|
* @param methodName The name of the method to call.
|
||||||
* @param value The value to pass to the method.
|
* @param value The value to pass to the method.
|
||||||
*/
|
*/
|
||||||
@@ -1480,7 +1480,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
/**
|
/**
|
||||||
* Call a method taking one String on a view in the layout for this RemoteViews.
|
* Call a method taking one String on a view in the layout for this RemoteViews.
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the view on which to call the method.
|
||||||
* @param methodName The name of the method to call.
|
* @param methodName The name of the method to call.
|
||||||
* @param value The value to pass to the method.
|
* @param value The value to pass to the method.
|
||||||
*/
|
*/
|
||||||
@@ -1491,7 +1491,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
/**
|
/**
|
||||||
* Call a method taking one CharSequence on a view in the layout for this RemoteViews.
|
* Call a method taking one CharSequence on a view in the layout for this RemoteViews.
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the view on which to call the method.
|
||||||
* @param methodName The name of the method to call.
|
* @param methodName The name of the method to call.
|
||||||
* @param value The value to pass to the method.
|
* @param value The value to pass to the method.
|
||||||
*/
|
*/
|
||||||
@@ -1502,7 +1502,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
/**
|
/**
|
||||||
* Call a method taking one Uri on a view in the layout for this RemoteViews.
|
* Call a method taking one Uri on a view in the layout for this RemoteViews.
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the view on which to call the method.
|
||||||
* @param methodName The name of the method to call.
|
* @param methodName The name of the method to call.
|
||||||
* @param value The value to pass to the method.
|
* @param value The value to pass to the method.
|
||||||
*/
|
*/
|
||||||
@@ -1516,7 +1516,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
* <p class="note">The bitmap will be flattened into the parcel if this object is
|
* <p class="note">The bitmap will be flattened into the parcel if this object is
|
||||||
* sent across processes, so it may end up using a lot of memory, and may be fairly slow.</p>
|
* sent across processes, so it may end up using a lot of memory, and may be fairly slow.</p>
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the view on which to call the method.
|
||||||
* @param methodName The name of the method to call.
|
* @param methodName The name of the method to call.
|
||||||
* @param value The value to pass to the method.
|
* @param value The value to pass to the method.
|
||||||
*/
|
*/
|
||||||
@@ -1527,7 +1527,7 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
/**
|
/**
|
||||||
* Call a method taking one Bundle on a view in the layout for this RemoteViews.
|
* Call a method taking one Bundle on a view in the layout for this RemoteViews.
|
||||||
*
|
*
|
||||||
* @param viewId The id of the view whose text should change
|
* @param viewId The id of the view on which to call the method.
|
||||||
* @param methodName The name of the method to call.
|
* @param methodName The name of the method to call.
|
||||||
* @param value The value to pass to the method.
|
* @param value The value to pass to the method.
|
||||||
*/
|
*/
|
||||||
@@ -1536,10 +1536,11 @@ public class RemoteViews implements Parcelable, Filter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Call a method taking one Intent on a view in the layout for this RemoteViews.
|
||||||
*
|
*
|
||||||
* @param viewId
|
* @param viewId The id of the view on which to call the method.
|
||||||
* @param methodName
|
* @param methodName The name of the method to call.
|
||||||
* @param value
|
* @param value The {@link android.content.Intent} to pass the method.
|
||||||
*/
|
*/
|
||||||
public void setIntent(int viewId, String methodName, Intent value) {
|
public void setIntent(int viewId, String methodName, Intent value) {
|
||||||
addAction(new ReflectionAction(viewId, methodName, ReflectionAction.INTENT, value));
|
addAction(new ReflectionAction(viewId, methodName, ReflectionAction.INTENT, value));
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ preinstalled applications (such as the dialer) that you can access from your
|
|||||||
applications. You can choose what version of the Android system you want to
|
applications. You can choose what version of the Android system you want to
|
||||||
run in the emulator by configuring AVDs, and you can also customize the
|
run in the emulator by configuring AVDs, and you can also customize the
|
||||||
mobile device skin and key mappings. When launching the emulator and at runtime,
|
mobile device skin and key mappings. When launching the emulator and at runtime,
|
||||||
you can use a variety of commands and options to control the its behaviors.
|
you can use a variety of commands and options to control its behavior.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>The Android system image distributed in the SDK contains ARM machine code for
|
<p>The Android system image distributed in the SDK contains ARM machine code for
|
||||||
|
|||||||
@@ -516,7 +516,7 @@ the keys of your keyboard. </p>
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Audio volume up button</td>
|
<td>Audio volume up button</td>
|
||||||
<td>KEYPAD_PLUS, Ctrl-5</td>
|
<td>KEYPAD_PLUS, Ctrl-F5</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ is presented to the user when launching the application for the first time. Each
|
|||||||
activity can then start another activity in order to perform different actions. Each time a new
|
activity can then start another activity in order to perform different actions. Each time a new
|
||||||
activity starts, the previous activity is stopped, but the system preserves the activity
|
activity starts, the previous activity is stopped, but the system preserves the activity
|
||||||
in a stack (the "back stack"). When a new activity starts, it is pushed onto the back stack and
|
in a stack (the "back stack"). When a new activity starts, it is pushed onto the back stack and
|
||||||
takes user focus. The back stack abides to the basic "last in, first out" queue mechanism,
|
takes user focus. The back stack abides to the basic "last in, first out" stack mechanism,
|
||||||
so, when the user is done with the current activity and presses the <em>Back</em> button, it
|
so, when the user is done with the current activity and presses the <em>Back</em> button, it
|
||||||
is popped from the stack (and destroyed) and the previous activity resumes. (The back stack is
|
is popped from the stack (and destroyed) and the previous activity resumes. (The back stack is
|
||||||
discussed more in the <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks
|
discussed more in the <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ handset design.</p>
|
|||||||
|
|
||||||
<p>For example—to continue with the news application example—the application can embed
|
<p>For example—to continue with the news application example—the application can embed
|
||||||
two fragments in <em>Activity A</em>, when running on a tablet-sized device. However, on a
|
two fragments in <em>Activity A</em>, when running on a tablet-sized device. However, on a
|
||||||
handset-sized screen, there's not be enough room for both fragments, so <em>Activity A</em> includes
|
handset-sized screen, there's not enough room for both fragments, so <em>Activity A</em> includes
|
||||||
only the fragment for the list of articles, and when the user selects an article, it starts
|
only the fragment for the list of articles, and when the user selects an article, it starts
|
||||||
<em>Activity B</em>, which includes the second fragment to read the article. Thus, the application
|
<em>Activity B</em>, which includes the second fragment to read the article. Thus, the application
|
||||||
supports both tablets and handsets by reusing fragments in different combinations, as illustrated in
|
supports both tablets and handsets by reusing fragments in different combinations, as illustrated in
|
||||||
|
|||||||
@@ -249,12 +249,20 @@ if (!mBluetoothAdapter.isEnabled()) {
|
|||||||
<p>A dialog will appear requesting user permission to enable Bluetooth, as shown
|
<p>A dialog will appear requesting user permission to enable Bluetooth, as shown
|
||||||
in Figure 1. If the user responds "Yes," the system will begin to enable Bluetooth
|
in Figure 1. If the user responds "Yes," the system will begin to enable Bluetooth
|
||||||
and focus will return to your application once the process completes (or fails).</p>
|
and focus will return to your application once the process completes (or fails).</p>
|
||||||
<p>If enabling Bluetooth succeeds, your Activity will receive the {@link
|
|
||||||
|
<p>The {@code REQUEST_ENABLE_BT} constant passed to {@link
|
||||||
|
android.app.Activity#startActivityForResult(Intent,int) startActivityForResult()} is a locally
|
||||||
|
defined integer (which must be greater than 0), that the system passes back to you in your
|
||||||
|
{@link
|
||||||
|
android.app.Activity#onActivityResult(int,int,Intent) onActivityResult()} implementation as the
|
||||||
|
<code>requestCode</code> parameter.</p>
|
||||||
|
|
||||||
|
<p>If enabling Bluetooth succeeds, your activity receives the {@link
|
||||||
android.app.Activity#RESULT_OK} result code in the {@link
|
android.app.Activity#RESULT_OK} result code in the {@link
|
||||||
android.app.Activity#onActivityResult(int,int,Intent) onActivityResult()}
|
android.app.Activity#onActivityResult(int,int,Intent) onActivityResult()}
|
||||||
callback. If Bluetooth was not enabled
|
callback. If Bluetooth was not enabled
|
||||||
due to an error (or the user responded "No") then the result code will be {@link
|
due to an error (or the user responded "No") then the result code is {@link
|
||||||
android.app.Activity#RESULT_CANCELED}.</p>
|
android.app.Activity#RESULT_CANCELED}.</p>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
@@ -431,11 +439,11 @@ startActivity(discoverableIntent);
|
|||||||
|
|
||||||
<p>A dialog will be displayed, requesting user permission to make the device
|
<p>A dialog will be displayed, requesting user permission to make the device
|
||||||
discoverable, as shown in Figure 2. If the user responds "Yes," then the device
|
discoverable, as shown in Figure 2. If the user responds "Yes," then the device
|
||||||
will become discoverable for the specified amount of time. Your Activity will
|
will become discoverable for the specified amount of time. Your activity will
|
||||||
then receive a call to the {@link android.app.Activity#onActivityResult(int,int,Intent)
|
then receive a call to the {@link android.app.Activity#onActivityResult(int,int,Intent)
|
||||||
onActivityResult())} callback, with the result code equal to the duration that the device
|
onActivityResult())} callback, with the result code equal to the duration that the device
|
||||||
is discoverable. If the user responded "No" or if an error occurred, the result code will
|
is discoverable. If the user responded "No" or if an error occurred, the result code will
|
||||||
be Activity.RESULT_CANCELLED.</p>
|
be {@link android.app.Activity#RESULT_CANCELED}.</p>
|
||||||
|
|
||||||
<p class="note"><strong>Note:</strong> If Bluetooth has not been enabled on the device,
|
<p class="note"><strong>Note:</strong> If Bluetooth has not been enabled on the device,
|
||||||
then enabling device discoverability will automatically enable Bluetooth.</p>
|
then enabling device discoverability will automatically enable Bluetooth.</p>
|
||||||
@@ -568,7 +576,7 @@ socket.</p>
|
|||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
<p>The {@link android.bluetooth.BluetoothServerSocket#accept()} call should not
|
<p>The {@link android.bluetooth.BluetoothServerSocket#accept()} call should not
|
||||||
be executed in the main Activity UI thread because it is a blocking call and
|
be executed in the main activity UI thread because it is a blocking call and
|
||||||
will prevent any other interaction with the application. It usually makes
|
will prevent any other interaction with the application. It usually makes
|
||||||
sense to do all work with a {@link android.bluetooth.BluetoothServerSocket} or {@link
|
sense to do all work with a {@link android.bluetooth.BluetoothServerSocket} or {@link
|
||||||
android.bluetooth.BluetoothSocket} in a new
|
android.bluetooth.BluetoothSocket} in a new
|
||||||
@@ -696,7 +704,7 @@ android.bluetooth.BluetoothSocket#connect()} method times out (after about
|
|||||||
12 seconds), then it will throw an exception.</p>
|
12 seconds), then it will throw an exception.</p>
|
||||||
<p>Because {@link
|
<p>Because {@link
|
||||||
android.bluetooth.BluetoothSocket#connect()} is a blocking call, this connection
|
android.bluetooth.BluetoothSocket#connect()} is a blocking call, this connection
|
||||||
procedure should always be performed in a thread separate from the main Activity
|
procedure should always be performed in a thread separate from the main activity
|
||||||
thread.</p>
|
thread.</p>
|
||||||
<p class="note">Note: You should always ensure that the device is not performing
|
<p class="note">Note: You should always ensure that the device is not performing
|
||||||
device discovery when you call {@link
|
device discovery when you call {@link
|
||||||
@@ -838,7 +846,7 @@ private class ConnectedThread extends Thread {
|
|||||||
try {
|
try {
|
||||||
// Read from the InputStream
|
// Read from the InputStream
|
||||||
bytes = mmInStream.read(buffer);
|
bytes = mmInStream.read(buffer);
|
||||||
// Send the obtained bytes to the UI Activity
|
// Send the obtained bytes to the UI activity
|
||||||
mHandler.obtainMessage(MESSAGE_READ, bytes, -1, buffer)
|
mHandler.obtainMessage(MESSAGE_READ, bytes, -1, buffer)
|
||||||
.sendToTarget();
|
.sendToTarget();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -847,14 +855,14 @@ private class ConnectedThread extends Thread {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call this from the main Activity to send data to the remote device */
|
/* Call this from the main activity to send data to the remote device */
|
||||||
public void write(byte[] bytes) {
|
public void write(byte[] bytes) {
|
||||||
try {
|
try {
|
||||||
mmOutStream.write(bytes);
|
mmOutStream.write(bytes);
|
||||||
} catch (IOException e) { }
|
} catch (IOException e) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call this from the main Activity to shutdown the connection */
|
/* Call this from the main activity to shutdown the connection */
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
try {
|
try {
|
||||||
mmSocket.close();
|
mmSocket.close();
|
||||||
@@ -866,12 +874,12 @@ private class ConnectedThread extends Thread {
|
|||||||
<p>The constructor acquires the necessary streams and once executed, the thread
|
<p>The constructor acquires the necessary streams and once executed, the thread
|
||||||
will wait for data to come through the InputStream. When {@link
|
will wait for data to come through the InputStream. When {@link
|
||||||
java.io.InputStream#read(byte[])} returns with
|
java.io.InputStream#read(byte[])} returns with
|
||||||
bytes from the stream, the data is sent to the main Activity using a member
|
bytes from the stream, the data is sent to the main activity using a member
|
||||||
Handler from the parent class. Then it goes back and waits for more bytes from
|
Handler from the parent class. Then it goes back and waits for more bytes from
|
||||||
the stream.</p>
|
the stream.</p>
|
||||||
|
|
||||||
<p>Sending outgoing data is as simple as calling the thread's
|
<p>Sending outgoing data is as simple as calling the thread's
|
||||||
<code>write()</code> method from the main Activity and passing in the bytes to
|
<code>write()</code> method from the main activity and passing in the bytes to
|
||||||
be sent. This method then simply calls {@link
|
be sent. This method then simply calls {@link
|
||||||
java.io.OutputStream#write(byte[])} to send the data to the remote device.</p>
|
java.io.OutputStream#write(byte[])} to send the data to the remote device.</p>
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ Open the Notepadv2 class.</p>
|
|||||||
menu callback used for the options menu. Here, we add just one line, which will add a menu item
|
menu callback used for the options menu. Here, we add just one line, which will add a menu item
|
||||||
to delete a note. Call <code>menu.add()</code> like so:
|
to delete a note. Call <code>menu.add()</code> like so:
|
||||||
<pre>
|
<pre>
|
||||||
public void onCreateContextMenu(Menu menu, View v, ContextMenuInfo menuInfo) {
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||||
super.onCreateContextMenu(menu, v, menuInfo);
|
super.onCreateContextMenu(menu, v, menuInfo);
|
||||||
menu.add(0, DELETE_ID, 0, R.string.menu_delete);
|
menu.add(0, DELETE_ID, 0, R.string.menu_delete);
|
||||||
}</pre>
|
}</pre>
|
||||||
|
|||||||
@@ -91,31 +91,30 @@ android.widget.Button} element:
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="10dp"
|
android:padding="10dp"
|
||||||
android:background="@drawable/android_button" />
|
android:background="@drawable/android_button"
|
||||||
|
android:onClick="onButtonClicked"/>
|
||||||
</pre>
|
</pre>
|
||||||
<p>The <code>android:background</code> attribute specifies the drawable resource to use for the
|
<p>The <code>android:background</code> attribute specifies the drawable resource to use for the
|
||||||
button background (which, when saved at <code>res/drawable/android.xml</code>, is
|
button background (which, when saved at <code>res/drawable/android.xml</code>, is
|
||||||
referenced as <code>@drawable/android</code>). This replaces the normal background image
|
referenced as <code>@drawable/android</code>). This replaces the normal background image
|
||||||
used for buttons throughout the system. In order for the drawable to change its image based on
|
applied by the system with the drawable created above, which changes its image based on
|
||||||
the button state, the image must be applied to the background.</p>
|
the button state.</p>
|
||||||
|
<p>The attribute <code>android:onClick</code> specifies the name of a method in your activity
|
||||||
|
that the system should call when the user clicks the button. You'll create that method next.</p>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>To make the button do something when pressed, add the following
|
<li>To make the button do something when pressed, add the following
|
||||||
code at the end of the {@link android.app.Activity#onCreate(Bundle) onCreate()} method:
|
method inside your {@link android.app.Activity} class:
|
||||||
<pre>
|
<pre>
|
||||||
final Button button = (Button) findViewById(R.id.button);
|
public void onButtonClicked(View v) {
|
||||||
button.setOnClickListener(new OnClickListener() {
|
// Do something when the button is clicked
|
||||||
public void onClick(View v) {
|
Toast.makeText(HelloFormStuff.this, "Button clicked", Toast.LENGTH_SHORT).show();
|
||||||
// Perform action on clicks
|
}
|
||||||
Toast.makeText(HelloFormStuff.this, "Beep Bop", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</pre>
|
</pre>
|
||||||
<p>This captures the {@link android.widget.Button} from the layout, then adds an {@link
|
<p>When you specify this kind of method, which is used in your layout file with the {@code
|
||||||
android.view.View.OnClickListener}. The {@link android.view.View.OnClickListener}
|
android:onClick} attribute, the method must be <code>public</code>, have a <code>void</code> return
|
||||||
must implement the {@link android.view.View.OnClickListener#onClick(View)} callback method, which
|
value, and accept a single {@code android.view.View} parameter. When the system calls this method,
|
||||||
defines the action to be made when the button is clicked. In this example, a
|
it passes the {@code android.view.View} that was clicked.</p>
|
||||||
{@link android.widget.Toast} message will be displayed.</p>
|
|
||||||
</li>
|
</li>
|
||||||
<li>Now run the application.</li>
|
<li>Now run the application.</li>
|
||||||
</ol>
|
</ol>
|
||||||
@@ -183,34 +182,33 @@ element (inside the {@link android.widget.LinearLayout}):
|
|||||||
<CheckBox android:id="@+id/checkbox"
|
<CheckBox android:id="@+id/checkbox"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="check it out" />
|
android:text="check it out"
|
||||||
|
android:onClick="onCheckboxClicked"/>
|
||||||
</pre>
|
</pre>
|
||||||
|
<p>The attribute <code>android:onClick</code> specifies the name of a method in your activity
|
||||||
|
that the system should call when the user clicks the check box. You'll create that method next.</p>
|
||||||
</li>
|
</li>
|
||||||
<li>To do something when the state is changed, add the following code
|
<li>To do something when the state is changed, add the following method inside your {@link
|
||||||
to the end of the {@link android.app.Activity#onCreate(Bundle) onCreate()} method:
|
android.app.Activity} class:</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
final CheckBox checkbox = (CheckBox) findViewById(R.id.checkbox);
|
public void onCheckboxClicked(View v) {
|
||||||
checkbox.setOnClickListener(new OnClickListener() {
|
// Perform action on clicks, depending on whether it's now checked
|
||||||
public void onClick(View v) {
|
if (((CheckBox) v).isChecked()) {
|
||||||
// Perform action on clicks, depending on whether it's now checked
|
Toast.makeText(HelloFormStuff.this, "Selected", Toast.LENGTH_SHORT).show();
|
||||||
if (((CheckBox) v).isChecked()) {
|
} else {
|
||||||
Toast.makeText(HelloFormStuff.this, "Selected", Toast.LENGTH_SHORT).show();
|
Toast.makeText(HelloFormStuff.this, "Not selected", Toast.LENGTH_SHORT).show();
|
||||||
} else {
|
|
||||||
Toast.makeText(HelloFormStuff.this, "Not selected", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
</pre>
|
</pre>
|
||||||
<p>This captures the {@link android.widget.CheckBox} element from the layout, then adds an {@link
|
|
||||||
android.view.View.OnClickListener}. The {@link android.view.View.OnClickListener} must implement the
|
<p>When you specify this kind of method, which is used in your layout file with the {@code
|
||||||
{@link android.view.View.OnClickListener#onClick(View)} callback method, which
|
android:onClick}
|
||||||
defines the action to be made when the checkbox is clicked. When clicked, {@link
|
attribute, the method must be <code>public</code>, have a <code>void</code> return value, and
|
||||||
android.widget.CompoundButton#isChecked()} is called to check the new state of the check box. If it
|
accept a single {@code android.view.View} parameter. When the system calls this method, it
|
||||||
has been checked, then a {@link android.widget.Toast} displays the message "Selected", otherwise it
|
passes the {@code android.view.View} that was clicked. In this example, the {@code
|
||||||
displays "Not selected". Note that the {@link android.view.View} object that is passed in the {@link
|
android.view.View} is cast to a {@link android.widget.CheckBox} to determine whether the widget
|
||||||
android.view.View.OnClickListener#onClick(View)} callback must be cast to a {@link
|
has been checked or unchecked. The {@link android.widget.CheckBox} widget
|
||||||
android.widget.CheckBox} because the {@link android.widget.CompoundButton#isChecked()} method is
|
|
||||||
not defined by the parent {@link android.view.View} class. The {@link android.widget.CheckBox}
|
|
||||||
handles its own state changes, so you only need to query the current state.</p>
|
handles its own state changes, so you only need to query the current state.</p>
|
||||||
</li>
|
</li>
|
||||||
<li>Run it.</li>
|
<li>Run it.</li>
|
||||||
@@ -240,44 +238,44 @@ android.widget.LinearLayout}):
|
|||||||
<RadioButton android:id="@+id/radio_red"
|
<RadioButton android:id="@+id/radio_red"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Red" />
|
android:text="Red"
|
||||||
|
android:onClick="onRadioButtonClicked"/>
|
||||||
<RadioButton android:id="@+id/radio_blue"
|
<RadioButton android:id="@+id/radio_blue"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Blue" />
|
android:text="Blue"
|
||||||
|
android:onClick="onRadioButtonClicked"/>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</pre>
|
</pre>
|
||||||
<p>It's important that the {@link android.widget.RadioButton}s are grouped together by the {@link
|
<p>It's important that the {@link android.widget.RadioButton}s are grouped together by the {@link
|
||||||
android.widget.RadioGroup} element so that no more than one can be selected at a time. This logic
|
android.widget.RadioGroup} element so that no more than one can be selected at a time. This logic
|
||||||
is automatically handled by the Android system. When one {@link android.widget.RadioButton} within
|
is automatically handled by the Android system. When one {@link android.widget.RadioButton} within
|
||||||
a group is selected, all others are automatically deselected.</p>
|
a group is selected, all others are automatically deselected.</p>
|
||||||
|
<p>The attribute <code>android:onClick</code> specifies the name of a method in your activity
|
||||||
|
that the system should call when the user clicks the radio button. You'll create that method
|
||||||
|
next.</p>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>To do something when each {@link android.widget.RadioButton} is selected, you need an
|
<li>To do something when each {@link android.widget.RadioButton} is selected, add the following
|
||||||
{@link android.view.View.OnClickListener}. In this case, you want the listener to be re-usable, so
|
method inside your {@link android.app.Activity} class:</p>
|
||||||
add the following code to create a new member in the <code>HelloFormStuff</code> Activity:
|
|
||||||
<pre>
|
<pre>
|
||||||
private OnClickListener radio_listener = new OnClickListener() {
|
public void onRadioButtonClicked(View v) {
|
||||||
public void onClick(View v) {
|
// Perform action on clicks
|
||||||
// Perform action on clicks
|
RadioButton rb = (RadioButton) v;
|
||||||
RadioButton rb = (RadioButton) v;
|
Toast.makeText(HelloFormStuff.this, rb.getText(), Toast.LENGTH_SHORT).show();
|
||||||
Toast.makeText(HelloFormStuff.this, rb.getText(), Toast.LENGTH_SHORT).show();
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
</pre>
|
</pre>
|
||||||
<p>First, the {@link android.view.View} that is passed to the {@link
|
|
||||||
android.view.View.OnClickListener#onClick(View)} method is cast into a RadioButton. Then a
|
<p>When you specify this kind of method, which is used in your layout file with the {@code
|
||||||
{@link android.widget.Toast} message displays the selected radio button's text.</p>
|
android:onClick}
|
||||||
<li>Now, at the bottom of the {@link android.app.Activity#onCreate(Bundle) onCreate()} method, add
|
attribute, the method must be <code>public</code>, have a <code>void</code> return value, and
|
||||||
the following:
|
accept a single {@code android.view.View} parameter. When the system calls this method, it
|
||||||
<pre>
|
passes the {@code android.view.View} that was clicked.</p>
|
||||||
final RadioButton radio_red = (RadioButton) findViewById(R.id.radio_red);
|
<p>Because each {@link android.widget.RadioButton} widget is grouped into a {@link
|
||||||
final RadioButton radio_blue = (RadioButton) findViewById(R.id.radio_blue);
|
android.widget.RadioGroup}, each widget handles its own state changes when a new button is
|
||||||
radio_red.setOnClickListener(radio_listener);
|
selected.</p>
|
||||||
radio_blue.setOnClickListener(radio_listener);
|
</li>
|
||||||
</pre>
|
|
||||||
<p>This captures each of the {@link android.widget.RadioButton}s from the layout and adds the
|
|
||||||
newly-created {@link android.view.View.OnClickListener} to each.</p>
|
|
||||||
<li>Run the application.</li>
|
<li>Run the application.</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
@@ -303,31 +301,35 @@ element (inside the {@link android.widget.LinearLayout}):
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textOn="Vibrate on"
|
android:textOn="Vibrate on"
|
||||||
android:textOff="Vibrate off"/>
|
android:textOff="Vibrate off"
|
||||||
|
android:onClick="onToggleClicked"/>
|
||||||
</pre>
|
</pre>
|
||||||
<p>The attributes <code>android:textOn</code> and <code>android:textOff</code> specify the text
|
<p>The attributes <code>android:textOn</code> and <code>android:textOff</code> specify the text
|
||||||
for the button when the button has been toggled on or off. The default values are "ON" and
|
for the button when the button has been toggled on or off. The default values are "ON" and
|
||||||
"OFF".</p>
|
"OFF".</p>
|
||||||
|
<p>The attribute <code>android:onClick</code> specifies the name of a method in your activity
|
||||||
|
that the system should call when the user clicks the button. You'll create that method next.</p>
|
||||||
</li>
|
</li>
|
||||||
<li>To do something when the state is changed, add the following code
|
<li>To do something when the user clicks the button, add the following
|
||||||
to the end of the {@link android.app.Activity#onCreate(Bundle) onCreate()} method:
|
method inside your {@link android.app.Activity} class:</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
final ToggleButton togglebutton = (ToggleButton) findViewById(R.id.togglebutton);
|
public void onToggleClicked(View v) {
|
||||||
togglebutton.setOnClickListener(new OnClickListener() {
|
// Perform action on clicks
|
||||||
public void onClick(View v) {
|
if (((ToggleButton) v).isChecked()) {
|
||||||
// Perform action on clicks
|
Toast.makeText(HelloFormStuff.this, "Toggle on", Toast.LENGTH_SHORT).show();
|
||||||
if (togglebutton.isChecked()) {
|
} else {
|
||||||
Toast.makeText(HelloFormStuff.this, "Checked", Toast.LENGTH_SHORT).show();
|
Toast.makeText(HelloFormStuff.this, "Toggle off", Toast.LENGTH_SHORT).show();
|
||||||
} else {
|
|
||||||
Toast.makeText(HelloFormStuff.this, "Not checked", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
</pre>
|
</pre>
|
||||||
<p>This captures the {@link android.widget.ToggleButton} element from the layout, then adds an
|
|
||||||
{@link android.view.View.OnClickListener}. The {@link android.view.View.OnClickListener} must
|
<p>When you specify this kind of method, which is used in your layout file with the {@code
|
||||||
implement the {@link android.view.View.OnClickListener#onClick(View)} callback method, which
|
android:onClick}
|
||||||
defines the action to perform when the button is clicked. In this example, the callback
|
attribute, the method must be <code>public</code>, have a <code>void</code> return value, and
|
||||||
|
accept a single {@code android.view.View} parameter. When the system calls this method, it
|
||||||
|
passes the {@code android.view.View} that was clicked.</p>
|
||||||
|
<p>In this example, the callback
|
||||||
method checks the new state of the button, then shows a {@link android.widget.Toast} message that
|
method checks the new state of the button, then shows a {@link android.widget.Toast} message that
|
||||||
indicates the current state.</p>
|
indicates the current state.</p>
|
||||||
|
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ public int size() {
|
|||||||
new class constructor:
|
new class constructor:
|
||||||
<pre>
|
<pre>
|
||||||
public HelloItemizedOverlay(Drawable defaultMarker, Context context) {
|
public HelloItemizedOverlay(Drawable defaultMarker, Context context) {
|
||||||
super(defaultMarker);
|
super(boundCenterBottom(defaultMarker));
|
||||||
mContext = context;
|
mContext = context;
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
|||||||
Reference in New Issue
Block a user