Search code examples
androiddelphibuttonsharedefault

How to delete default Share App in Delphi code?


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?


Solution

    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)