3

I am creating an Android Application in Delphi, and I need a Button, which deletes the default Share App, if one is set.

E.g
I share a File via Gmail, and press 'Always'
The next time, this is the default app.

Is it possible to delete this in Code? Or can i open the App-Infos where it is possible to reset this option?

Nimantha
  • 6,405
  • 6
  • 28
  • 69
SoCrazzy
  • 107
  • 5

1 Answers1

1
  1. clearPackagePreferredActivities() in PackageManager will clear the defaults of a particular app, whichever's package name you pass.

(https://stackoverflow.com/a/13072877/6517492)

  1. You can open the application settings screen programmatically. Java code:

    Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", activity.getPackageName(), null); intent.setData(uri); context.startActivity(intent);

(from https://stackoverflow.com/a/35456817/6517492)

mjn42
  • 830
  • 1
  • 8
  • 24
  • Is it possible to get the Package name of the Application, which is used as the default share for ACTION_SEND? – SoCrazzy Oct 10 '18 at 13:59
  • The [PackageManager](http://developer.android.com/reference/android/content/pm/PackageManager.html) API contains getPreferredActivities – mjn42 Oct 10 '18 at 14:04
  • See https://developer.android.com/reference/android/content/pm/PackageManager.html#getPreferredActivities(java.util.List%3Candroid.content.IntentFilter%3E,%20java.util.List%3Candroid.content.ComponentName%3E,%20java.lang.String) – mjn42 Oct 10 '18 at 14:09
  • 1
    I have solved the Problem with resolveActivity on the PackageManager. Thank you @mjn42 for the tip! – SoCrazzy Oct 15 '18 at 13:59