androidgoogle-nearbygoogle-nearby-connections

How to share via Nearby Share directly?


related Is there a way to share a link via Nearby Share & receive the link via a custom app on the second device using Nearby Connections API?

as @Xlythe's answer, using com.google.android.gms.nearby.sharing.EXTRA_REQUIRED_PACKAGE can launch a package from receiver by Nearby

Question is how can i send a file with intent extra to Nearby directly. guess i can use ACTION_SEND intent with Chooser dialog and make user select the Nearby button. But is there a way to send to Nearby bypassing the chooser dialog?

And one more, suppose that a file sent to a receiver device with EXTRA_REQUIRED_PACKAGE value. receiver would get notification from Nearby to accept it and system would launch the package from extra value? and is the package able to handle a file that was sent from Nearby?


Solution

  • Use the Intent action "com.google.android.gms.SHARE_NEARBY" and the package "com.google.android.gms" to directly launch Nearby Share.

    Yes, the system launches the package with the action "android.intent.action.VIEW" and the intent extras from the received data.