- uris
- an array of Uri(s) to push over Android Beam
- activity
- activity for which the Uri(s) will be pushed
Set one or more Android.Net.Uris to send using Android Beam (TM). Every Uri you provide must have either scheme 'file' or scheme 'content'.
For the data provided through this method, Android Beam tries to switch to alternate transports such as Bluetooth to achieve a fast transfer speed. Hence this method is very suitable for transferring large files such as pictures or songs.
The receiving side will store the content of each Uri in a file and present a notification to the user to open the file with a Android.Content.Intent with action Android.Content.Intent.ActionView. If multiple URIs are sent, the Android.Content.Intent will refer to the first of the stored files.
This method may be called at any time before Android.App.Activity.OnDestroy, but the URI(s) are only made available for Android Beam when the specified activity(s) are in resumed (foreground) state. The recommended approach is to call this method during your Activity's Android.App.Activity.OnCreate(Android.OS.Bundle) - see sample code below. This method does not immediately perform any I/O or blocking work, so is safe to call on your main thread.
NfcAdapter.SetBeamPushUris(Android.Net.Uri[], Android.App.Activity) and NfcAdapter.SetBeamPushUrisCallback(.ICreateBeamUrisCallback, Android.App.Activity) have priority over both NfcAdapter.setNdefPushMessage(android.nfc.NdefMessage, android.app.Activity, android.app.Activity...) and NfcAdapter.setNdefPushMessageCallback(android.nfc.NfcAdapter.CreateNdefMessageCallback, android.app.Activity, android.app.Activity...).
If NfcAdapter.SetBeamPushUris(Android.Net.Uri[], Android.App.Activity) is called with a null Uri array, and/or NfcAdapter.SetBeamPushUrisCallback(.ICreateBeamUrisCallback, Android.App.Activity) is called with a null callback, then the Uri push will be completely disabled for the specified activity(s).
Code example:
java Example
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); if (nfcAdapter == null) return; // NFC not available on this device nfcAdapter.setBeamPushUris(new Uri[] {uri1, uri2}, this); }
If your Activity wants to dynamically supply Uri(s), then set a callback using NfcAdapter.SetBeamPushUrisCallback(.ICreateBeamUrisCallback, Android.App.Activity) instead of using this method.
Do not pass in an Activity that has already been through Android.App.Activity.OnDestroy. This is guaranteed if you call this API during Android.App.Activity.OnCreate(Android.OS.Bundle).
If this device does not support alternate transports such as Bluetooth or WiFI, calling this method does nothing.
Requires the NoType:android/Manifest$permission;Href=../../../reference/android/Manifest.permission.html#NFC permission.