开发学院手机开发Android 开发 Android:BroadcastReceiver 阅读

Android:BroadcastReceiver

 2010-10-19 20:16:47 来源:WEB开发网   
核心提示:should not perform any operations that return a result to you asynchronously -- in particular, for interacting with services, you should use startService(Intent
should not perform any operations that return a result to you asynchronously -- in particular, for interacting with services, you should use startService(Intent) instead of bindService(Intent, ServiceConnection, int). If you wish to interact with a service that is already running, you can use peekService(Context, Intent).

The Intent filters used in registerReceiver(BroadcastReceiver, IntentFilter) and in application manifests are not guaranteed to be exclusive. They are hints to the operating system about how to find suitable recipients. It is possible for senders to force delivery to specific recipients, bypassing filter resolution. For this reason, onReceive() implementations should respond only to known actions, ignoring any unexpected Intents that they may receive.

Parameters

context The Context in which the receiver is running.

intent The Intent being received.

onReceive()函数当BroadcastReceiver收到新的Intent时才会执行。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public final void setResult (int code, String data, Bundle extras)

Since: API Level 1

Change all of the result data returned from this broadcasts; only works with broadcasts sent through Context.sendOrderedBroadcast. All current result data is replaced by the value given to this method.

This method does not work with non-ordered broadcasts such as those sent with Context.sendBroadcast

Parameters

code The new result code. Often uses the Activity RESULT_CANCELED and RESULT_OK constants, though the actual meaning of this value is ultimately up to the broadcaster.

data The new result data. This is an arbitrary string whose interpretation is up to the broadcaster; may be null.

extras The new extra data map. This is a Bundle holding arbitrary data, whose interpretation is up to the broadcaster. Can be set to null. This

上一页  1 2 3 4 5 6  下一页

Tags:Android BroadcastReceiver

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接