Every app has an “About us” section which speaks about the app, the company or the developer.
Every time a user decides to go to the “About Us” page, he or she is on a fact-finding mission, as well as looking for the story of the creator. Most of these apps share their social connections here so that the user gets easy access to connect & communicate with them thus building the user feedback.
After working on the same for 10+ times I thought why not this be done with a single line of code. So here it is, my post talking about how you can connect social media account in a single line of code.
Yes, you read it right! a single line of code.
Social accounts: Facebook, Twitter, LinkedIn, Instagram, PlayStore, GitHub, YouTube
You can send emails & also load any valid URL with this.
I made a Gist, it’s over on GitHub. Just insert that file into your application and call the necessary function with the needed data.
This is how the Util class works,
- Check internet connection,
- Check the availability of the application,
- If available redirect to the concerned screen, else open the page in the browser.
1. Check Internet Connection:
2. Check the availability of the application:
3. If app available redirect to the concerned screen else opens the page in browser:
It is a utility class used to connect social media accounts. All the functions are the static function so need to create an instance, you can directly call the method using the function name along with the class name like
SocialConnection contains the following methods. For all this method you need to pass the Context and the unique ID of the account as arguments.
- connectFacebook : connect Facebook account.
- connectTwitter : connect Twitter handle.
- connectInstagram : link Instagram id.
- sendMail : send the e-mail with/without a subject.
- connectLinkedIn : connect LinkedIn profile .
- connectYouTube : link to YouTube channel.
- connectGitHub : connect GitHub profile.
- connectPlayStoreApp : link an app.
- listPlayStoreApps : list out all apps of a Developer ID.
- loadURL : load a URL.
- setCheckInternetConnection : check internet connection based on the boolean flag.
- setShowErrorMessage : Toast network error message based on the flag .
- setNetworkErrorMessage : to set network error message.
Latest posts by Jaison Fernando (see all)
- Phone number auth using Firebase Authentication SDK - March 20, 2020
- Password-less email auth using Firebase Authentication SDK - March 9, 2020
- How to use SharedPreferences API in Android? - February 10, 2020