From 6aad995042599dd0f5def79fea85cee90439c9a8 Mon Sep 17 00:00:00 2001
From: Scott Main You can now use the mService reference to communicate with the Google Play service. Important: Remember to unbind from the In-app Billing service when you are done with your {@link android.app.Activity}. If you don’t unbind, the open service connection could cause your device’s performance to degrade. This example shows how to perform the unbind operation on a service connection to In-app Billing called {@code mServiceConn} by overriding the activity’s {@link android.app.Activity#onDestroy onDestroy} method.
@Override
public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- bindService(new
- Intent("com.android.vending.billing.InAppBillingService.BIND"),
- mServiceConn, Context.BIND_AUTO_CREATE);
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ bindService(new
+ Intent("com.android.vending.billing.InAppBillingService.BIND"),
+ mServiceConn, Context.BIND_AUTO_CREATE);
@Override
public void onDestroy() {
- if (mServiceConn != null) {
- unbindService(mServiceConn);
- }
+ super.onDestroy();
+ if (mServiceConn != null) {
+ unbindService(mServiceConn);
+ }
}
diff --git a/docs/html/guide/topics/connectivity/wifip2p.jd b/docs/html/guide/topics/connectivity/wifip2p.jd
index 82c9abd..bbf30fd 100644
--- a/docs/html/guide/topics/connectivity/wifip2p.jd
+++ b/docs/html/guide/topics/connectivity/wifip2p.jd
@@ -237,16 +237,16 @@ page.title=Wi-Fi Direct
*/
public class WiFiDirectBroadcastReceiver extends BroadcastReceiver {
- private WifiP2pManager manager;
- private Channel channel;
- private MyWiFiActivity activity;
+ private WifiP2pManager mManager;
+ private Channel mChannel;
+ private MyWiFiActivity mActivity;
public WiFiDirectBroadcastReceiver(WifiP2pManager manager, Channel channel,
MyWifiActivity activity) {
super();
- this.manager = manager;
- this.channel = channel;
- this.activity = activity;
+ this.mManager = manager;
+ this.mChannel = channel;
+ this.mActivity = activity;
}
@Override
@@ -333,7 +333,7 @@ protected void onCreate(Bundle savedInstanceState){
...
mManager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
mChannel = mManager.initialize(this, getMainLooper(), null);
- mReceiver = new WiFiDirectBroadcastReceiver(manager, channel, this);
+ mReceiver = new WiFiDirectBroadcastReceiver(mManager, mChannel, this);
...
}
@@ -397,7 +397,7 @@ protected void onPause() {
that the discovery process succeeded and does not provide any information about the actual peers
that it discovered, if any:
-manager.discoverPeers(channel, new WifiP2pManager.ActionListener() { +mManager.discoverPeers(channel, new WifiP2pManager.ActionListener() { @Override public void onSuccess() { ... @@ -425,8 +425,8 @@ if (WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION.equals(action)) { // request available peers from the wifi p2p manager. This is an // asynchronous call and the calling activity is notified with a // callback on PeerListListener.onPeersAvailable() - if (manager != null) { - manager.requestPeers(channel, myPeerListListener); + if (mManager != null) { + mManager.requestPeers(mChannel, myPeerListListener); } }@@ -453,7 +453,7 @@ if (WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION.equals(action)) { WifiP2pDevice device; WifiP2pConfig config = new WifiP2pConfig(); config.deviceAddress = device.deviceAddress; -manager.connect(channel, config, new ActionListener() { +mManager.connect(mChannel, config, new ActionListener() { @Override public void onSuccess() { diff --git a/docs/html/guide/topics/manifest/manifest-intro.jd b/docs/html/guide/topics/manifest/manifest-intro.jd index a130f7d..d25a513 100644 --- a/docs/html/guide/topics/manifest/manifest-intro.jd +++ b/docs/html/guide/topics/manifest/manifest-intro.jd @@ -115,6 +115,7 @@ other mention of the element name. <provider> <grant-uri-permission /> <meta-data /> + <path-permission /> </provider> <uses-library /> diff --git a/docs/html/guide/topics/ui/layout/gridview.jd b/docs/html/guide/topics/ui/layout/gridview.jd index 67bdd0f..84c3dab 100644 --- a/docs/html/guide/topics/ui/layout/gridview.jd +++ b/docs/html/guide/topics/ui/layout/gridview.jd @@ -170,7 +170,7 @@ image is resized and cropped to fit in these dimensions, as appropriate. be cropped toward the center (if necessary).
When your activity is destroyed because the user presses Back or the activity finishes itself, the system's concept of that {@link android.app.Activity} instance is gone forever because the behavior indicates the activity is no longer needed. However, if the system destroys -the activity due to system constraints (rather than normal app behavior), then althought the actual +the activity due to system constraints (rather than normal app behavior), then although the actual {@link android.app.Activity} instance is gone, the system remembers that it existed such that if the user navigates back to it, the system creates a new instance of the activity using a set of saved data that describes the state of the activity when it was destroyed. The saved data that the @@ -126,7 +126,7 @@ can save the state of the view hierarchy.
state from the {@link android.os.Bundle} that the system passes your activity. Both the {@link android.app.Activity#onCreate onCreate()} and {@link android.app.Activity#onRestoreInstanceState onRestoreInstanceState()} callback methods receive -the same {@link android.os.Bundle} that containes the instance state information. +the same {@link android.os.Bundle} that contains the instance state information.Because the {@link android.app.Activity#onCreate onCreate()} method is called whether the system is creating a new instance of your activity or recreating a previous one, you must check diff --git a/docs/html/training/basics/activity-lifecycle/starting.jd b/docs/html/training/basics/activity-lifecycle/starting.jd index dd17304..dce6e30 100644 --- a/docs/html/training/basics/activity-lifecycle/starting.jd +++ b/docs/html/training/basics/activity-lifecycle/starting.jd @@ -265,7 +265,7 @@ signal that your activity instance is being completely removed from the system m with the activity and your activity should perform most cleanup during {@link android.app.Activity#onPause} and {@link android.app.Activity#onStop}. However, if your activity includes background threads that you created during {@link -android.app.Activity#onCreate onCreate()} or other other long-running resources that could +android.app.Activity#onCreate onCreate()} or other long-running resources that could potentially leak memory if not properly closed, you should kill them during {@link android.app.Activity#onDestroy}.
diff --git a/docs/html/training/basics/data-storage/shared-preferences.jd b/docs/html/training/basics/data-storage/shared-preferences.jd index 67f45cb..099da67 100644 --- a/docs/html/training/basics/data-storage/shared-preferences.jd +++ b/docs/html/training/basics/data-storage/shared-preferences.jd @@ -115,7 +115,7 @@ present. For example:SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE); -long default = getResources().getInteger(R.string.saved_high_score_default)); -long highScore = sharedPref.getInt(getString(R.string.saved_high_score), default); +int defaultValue = getResources().getInteger(R.string.saved_high_score_default); +long highScore = sharedPref.getInt(getString(R.string.saved_high_score), defaultValue);diff --git a/docs/html/training/basics/network-ops/xml.jd b/docs/html/training/basics/network-ops/xml.jd index b148257..0ea696d 100644 --- a/docs/html/training/basics/network-ops/xml.jd +++ b/docs/html/training/basics/network-ops/xml.jd @@ -551,5 +551,5 @@ private InputStream downloadUrl(String urlString) throws IOException { conn.setDoInput(true); // Starts the query conn.connect(); - InputStream stream = conn.getInputStream(); + return conn.getInputStream(); } diff --git a/docs/html/training/basics/supporting-devices/screens.jd b/docs/html/training/basics/supporting-devices/screens.jd index 8697cd5..1114f21 100644 --- a/docs/html/training/basics/supporting-devices/screens.jd +++ b/docs/html/training/basics/supporting-devices/screens.jd @@ -108,7 +108,7 @@ MyProject/
By default, the layout/main.xml
file is used for portrait orientation.
If you want a provide a special layout for landscape, including while on large screens, then +
If you want to provide a special layout for landscape, including while on large screens, then
you need to use both the large
and land
qualifier:
diff --git a/docs/html/training/custom-views/index.jd b/docs/html/training/custom-views/index.jd index 0661c05..cec75b4 100644 --- a/docs/html/training/custom-views/index.jd +++ b/docs/html/training/custom-views/index.jd @@ -17,12 +17,12 @@ next.link=create-view.htmlYou should also read
A better approach is to register and unregister the media button event receiver when your -application gains and losses the audio focus. This is covered in detail in the next lesson.
+application gains and loses the audio focus. This is covered in detail in the next lesson. diff --git a/docs/html/training/multiple-apks/texture.jd b/docs/html/training/multiple-apks/texture.jd index e4ea72b..c49cc95 100644 --- a/docs/html/training/multiple-apks/texture.jd +++ b/docs/html/training/multiple-apks/texture.jd @@ -90,8 +90,8 @@ cell represents an APK.When you construct an intent, you must specify the action you want the intent to "trigger." Android defines several actions, including {@link android.content.Intent#ACTION_SEND} which, as you can probably guess, indicates that the intent is sending data from one activity to another, -even across process boundaries. To send data to another activity, all you need to do is speicify +even across process boundaries. To send data to another activity, all you need to do is specify the data and its type, the system will identify compatible receiving activities and display them to the user (if there are multiple options) or immediately start the activity (if there is only one option). Similarly, you can advertise the data types that your activities support receiving -- cgit v1.1