The local BillingService processes callbacks from IMarketBillingService when your activity is not running.
The link ( http://developer.android.com/reference/android/app/Activity.html ) says:
“If an action is paused or stopped, the system can refuse the action from memory, either asking it to finish, or simply killing it to process. When it is displayed to the user again, it must be completely restarted and restored to its previous state."
If you, for example, call a RESTORE_TRANSACTIONS billing request, responses from the Android Market service may take some time to arrive. Using the service, you know that you will always be responsible for the answers, regardless of the life cycle of the activity.
Just for fun, I tried to write a small test application and was sure. A running thread can invoke methods with paused or stopped activity. This thread can also change its UI, even if activity is not in the foreground. Launch the following application, press the main screen to stop the application. Go back after 10 seconds and you will see that the TextView has changed ...
package com.example.playground; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.widget.TextView; public class MyActivity extends Activity { private static String TAG = MyActivity.class.getName(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Thread t = new Thread(new Runnable() { public void run() { try { Thread.sleep(10000); someMethod(); } catch (InterruptedException e) { Log.e(TAG, e.getMessage(), e); } } }); t.start(); } private void someMethod() { Log.d(TAG, "Some method called"); TextView tv = (TextView) findViewById(R.id.textfield); tv.setText("Called later"); } }
source share