0

How to start A application's specific activity in B application by link?

  1. Share a URI contains information about A's specific activity.
  2. If a user click that link in B app, start A app's specific activity.

this is my AndroidManifiest.xml code.

 <activity android:name = ".activity.PhotoActivity">
        <intent-filter >
            <data android:scheme="mine" android:host="photo"/>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.BROWSABLE"/>
        </intent-filter>
 </activity>

this is shareURI method.

 fun sendUri(videoId:String?, point:Long) {
    val sharedUri = "mine://photo?photo_id=$photoId&size=$size"

    val intent = Intent(Intent.ACTION_SEND)
    intent.type = "text/plain"
    intent.addCategory(Intent.CATEGORY_DEFAULT)
    intent.addCategory(Intent.CATEGORY_BROWSABLE)
    intent.data = Uri.parse(sharedUri)
    startActivity(Intent.createChooser(intent, "Share URL"))

}

But it's not working. when I try to share that link, chooser does not appear. and there's a message.

'All app associated with this action have been disabled, blocked, or are not installed.`

mel
  • 199
  • 1
  • 10
  • Update your question with the error that you are facing – Sagar May 14 '18 at 02:53
  • @Sagar sorry. I have error intent.ACTION_SEND not working. chooser is not appeared. and there's a message 'All app associated with this action have been disabled, blocked, or are not installed.' – mel May 14 '18 at 03:03
  • Try to remove one of `addCategory` line to see if it works. Also try to use the same Action you define in `intent-filter`, which is `ACTION_VIEW`, not `ACTION_SEND` – Tam Huynh May 14 '18 at 03:23
  • @TamHuynh Thank you for your time. I tried both but still not working. – mel May 14 '18 at 03:38
  • @mel.j try using intent.setDataAndType ( Uri.parse(sharedUri), "text/plain"), Instead of intent.type & intent.data – Sagar May 14 '18 at 03:50
  • @Sagar It still not working. `val intent = Intent(Intent.ACTION_SEND) intent.setDataAndType(Uri.parse(sharedUri), "text/plain") startActivity(Intent.createChooser(intent, "Share URL"))` could you show your sample code? – mel May 14 '18 at 03:56
  • @mel.j Do you see any error? – Sagar May 14 '18 at 03:58
  • @Sagar still same message : 'All app asociated with this action have been disabled, blocked, or are not installed.' – mel May 14 '18 at 04:06
  • Check this [SO](https://stackoverflow.com/questions/50072638/fileuriexposedexception-in-android) for some details of how to implement it. Its code is written in Java though. – Sagar May 14 '18 at 04:16
  • @Sagar Thank you for your time. but it didn't work. So I use firebase dynamic link. now it works. Anyway, Thanks again. – mel May 15 '18 at 02:49

1 Answers1

0

I use firebase DynamicLink. It's very useful.

mel
  • 199
  • 1
  • 10