I am integrating twitter in my application and want to show twitter post dialog as available in iphone looks like the Image below.
Can we have this dialog in Android and how?
I think it's a bad idea to trying copy UI from a platform to another.
I recommand you to use the share intent:
http://mobile.tutsplus.com/tutorials/android/android-sdk-implement-a-share-intent/
http://developer.android.com/training/sharing/send.html
It's really easy to use and integrated with the platform.
you can do this by finding twitter app from share intent if it is installed but if not you can handle that condition adn open your twitter app page as in my below code,since i found twitter4j hard to integrate and give inconsistence results.
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "subject");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, " text";
final PackageManager pm = v.getContext().getPackageManager();
final List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
boolean twtchk=false;
for (final ResolveInfo app : activityList) {
if ("com.twitter.android.PostActivity".equals(app.activityInfo.name)) {
final ActivityInfo activity = app.activityInfo;
System.out.println("package==="+activity.applicationInfo.packageName);
final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
shareIntent.setComponent(name);
v.getContext().startActivity(shareIntent);
twtchk=true;
break;
}
}
if(!twtchk)
{
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/yourapp"));
startActivity(intent);
}
Create this view in xml and use it. here is tutorial for posting string on twitter using twitter4j
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With