0

I'm trying to add a privacy policy link in my app, but when I click on the privacy policy link in app menu nothing happens.

This is my menu layout code

 <item n1:icon="@drawable/ic_help_teal_700_24dp" n1:id="@id/privacy_policy" n1:title="@string/privacy_policy"  />

and this is my strings code

<string name="privacy_policy"><a href="http://xxxxx/xxxxx/privacy_policy.html">Privacy Policy</a></string>

and this is the photo of the menu in my app

privacy policy menu link

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
John R
  • 3
  • 3
  • Do you have any code that handles the click? What you have shown us here is not enough information. Where is your code that is supposed to open something? – Chris K Apr 05 '19 at 19:06
  • No i don't have any code for that , because google play has removed my app and i need to add the privacy policy link inside my app . how i can fix that please mr ck1221 ?? – John R Apr 05 '19 at 19:13
  • This post tells you how to open a URL in the phones browser from your app. https://stackoverflow.com/questions/2201917/how-can-i-open-a-url-in-androids-web-browser-from-my-application You need to handle the link click just like you handle any other type of button or menu click and open your privacy policy url using the code in the link above – Chris K Apr 05 '19 at 19:18
  • Thank you i see the solution but i have no idea where i can add that code mr ck1221 – John R Apr 05 '19 at 19:29
  • I don't know that either. As I mentioned earlier, you have not provided us with enough information. We don't know how your application is structured. No one here can tell you where to put the code without more information. – Chris K Apr 05 '19 at 19:37
  • I suggest reading this article https://stackoverflow.com/help/how-to-ask – Chris K Apr 05 '19 at 19:39

1 Answers1

0

Add the following attributes to the TextView where you show your Privacy Policy link

<TextView
        android:id="@+id/privacy_policy_tv"
        ...
        android:autoLink="web"
        android:linksClickable="true"
        android:text="@string/privacy_policy" />

You may also need to set the LinkMovementMethod programmatically:

final TextView policy = (TextView) findViewById(R.id.privacy_policy_tv);
policy .setMovementMethod(LinkMovementMethod.getInstance());

Edit: Just spotted you're attempting to call this directly from a Navigation Menu. In that case you may do best to apply the advice in the comments and follow the link here, and launch an Intent to display your privacy policy.

PPartisan
  • 8,173
  • 4
  • 29
  • 48