Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How do I open Facebook, Twitter and Browser?

Discussion in 'Android' started by criistii22, Jan 13, 2012.

  1. criistii22

    criistii22

    Joined:
    Jan 18, 2011
    Posts:
    52
    Hi,

    I need my app to open facebook to my twitter account, facebook page or web site. Any idea how I can do this on android under Unity. Application.OpenURL doesn't seem to work.
    Idealy, i would like to try and open the FB or Twitter app if available, if not the web browser.

    Thanks,
     
  2. bug5532

    bug5532

    Joined:
    Aug 16, 2011
    Posts:
    307
    Application.OpenURL does work, e.g. Application.OpenURL("http://www.facebook.com/"); also works to open up the android market Application.OpenURL("market://details?id=com.blah.blah");
    I use this and it works fine.
     
  3. criistii22

    criistii22

    Joined:
    Jan 18, 2011
    Posts:
    52
    What about opening the Facebook application? (not the website)
     
  4. bug5532

    bug5532

    Joined:
    Aug 16, 2011
    Posts:
    307
    no idea, you'll probably need to write a plugin somehow :)
     
  5. Kencho

    Kencho

    Joined:
    Dec 26, 2011
    Posts:
    14
    As far as I can remember, it has to deal with permissions in the AndroidManifest.xml (what activities can launch your activity...). Anyways, when I try to access Facebook or Google+ websites from my Android browser, a popup asks me to use the app instead of the web version. I don't know if this is the norm, but may be a possibility anyways.

    PS: If going through the OpenURL path, make your users happy and use https instead of http. I'm still wondering why Facebook doesn't enable secure conections by default :-/
     
  6. fengchih

    fengchih

    Joined:
    Apr 10, 2012
    Posts:
    1
    Have you found the answer?
     
  7. ExCx

    ExCx

    Joined:
    Feb 7, 2013
    Posts:
    7
  8. DeveshPandey

    DeveshPandey

    Joined:
    Sep 30, 2012
    Posts:
    221
  9. luisanton

    luisanton

    Joined:
    Aug 25, 2009
    Posts:
    325
    With twitter you can also try 'intents' like this:

    Code (csharp):
    1.  
    2. void TweetScore() {
    3.         string TWITTER_ADDRESS = "http://twitter.com/intent/tweet";
    4.         string TWEET_LANGUAGE = "en";
    5.        
    6.         Application.OpenURL(TWITTER_ADDRESS +
    7.                            "?text=" + WWW.EscapeURL("I'm enjoying Slider, by @PlayMedusa!")) ;
    8. }
    9.