Sometimes we need to open user profile of Facebook, Twitter or LinkedIn by using the username in android.
To do this, we just create a uri to open the profile.
We can implement this in onclick() of any view.
For Facebook:
String url = "https://www.facebook.com/"+mFacebookUrlString;
Intent facebookAppIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
facebookAppIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(facebookAppIntent);
For Twitter:
String url = "https://www.twitter.com/"+mTwitterUrlString;
Intent twitterAppIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
twitterAppIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(twitterAppIntent);
For LinkedIn:
String url = "https://www.linkedin.com/in/"+mLinkedInurlString;
Intent linkedInAppIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
linkedInAppIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(linkedInAppIntent);
0 Comment(s)