android: exclude self from share intent (#1132)
This commit is contained in:
parent
b55960d743
commit
36225e4f92
@ -8,6 +8,7 @@ import android.graphics.Bitmap
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.ComponentName
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
import android.webkit.WebMessage
|
import android.webkit.WebMessage
|
||||||
@ -103,8 +104,10 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
|||||||
val shareIntent = Intent()
|
val shareIntent = Intent()
|
||||||
shareIntent.action = Intent.ACTION_SEND
|
shareIntent.action = Intent.ACTION_SEND
|
||||||
shareIntent.type = "text/plain"
|
shareIntent.type = "text/plain"
|
||||||
shareIntent.putExtra(Intent.EXTRA_TEXT, url);
|
shareIntent.putExtra(Intent.EXTRA_TEXT, url)
|
||||||
startActivity(Intent.createChooser(shareIntent, ""))
|
val chooser = Intent.createChooser(shareIntent, "")
|
||||||
|
chooser.putExtra(Intent.EXTRA_EXCLUDE_COMPONENTS, arrayOf(ComponentName(applicationContext, MainActivity::class.java)))
|
||||||
|
startActivity(chooser)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
|
Loading…
Reference in New Issue
Block a user