Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show Twitter Posting dialog Like Iphone

I am integrating twitter in my application and want to show twitter post dialog as available in iphone looks like the Image below.

enter image description here

Can we have this dialog in Android and how?

like image 489
Krishnakant Dalal Avatar asked Aug 23 '12 09:08

Krishnakant Dalal


3 Answers

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.

like image 127
Aerilys Avatar answered Nov 15 '22 06:11

Aerilys


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);
                    }
like image 21
mrYogi Avatar answered Nov 15 '22 06:11

mrYogi


Create this view in xml and use it. here is tutorial for posting string on twitter using twitter4j

like image 32
Jaiprakash Soni Avatar answered Nov 15 '22 05:11

Jaiprakash Soni