From 36225e4f926a532d5df2e09f7e8aea9028c21b8a Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Wed, 30 Jan 2019 12:46:43 -0800 Subject: [PATCH] android: exclude self from share intent (#1132) --- .../src/main/java/org/mozilla/sendandroid/MainActivity.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/java/org/mozilla/sendandroid/MainActivity.kt b/android/app/src/main/java/org/mozilla/sendandroid/MainActivity.kt index 954c7893..41eaaf66 100644 --- a/android/app/src/main/java/org/mozilla/sendandroid/MainActivity.kt +++ b/android/app/src/main/java/org/mozilla/sendandroid/MainActivity.kt @@ -8,6 +8,7 @@ import android.graphics.Bitmap import android.content.Context import android.content.Intent import android.annotation.SuppressLint +import android.content.ComponentName import android.net.Uri import android.webkit.WebView import android.webkit.WebMessage @@ -103,8 +104,10 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener { val shareIntent = Intent() shareIntent.action = Intent.ACTION_SEND shareIntent.type = "text/plain" - shareIntent.putExtra(Intent.EXTRA_TEXT, url); - startActivity(Intent.createChooser(shareIntent, "")) + shareIntent.putExtra(Intent.EXTRA_TEXT, url) + val chooser = Intent.createChooser(shareIntent, "") + chooser.putExtra(Intent.EXTRA_EXCLUDE_COMPONENTS, arrayOf(ComponentName(applicationContext, MainActivity::class.java))) + startActivity(chooser) } @SuppressLint("NewApi")