tags:

views:

179

answers:

2

Hi, i made news applicaion in android using RSS feed and now i want to share some news ie i want to upload links from my app to facebook, twitter etc.Is it possible? Thanks

+1  A: 

Yes it is. Twitter and Facebook has api for you to do those. Take a look at these Twitter Java APIs also checkout the facebook developer page

Sevki
Its not a my question. I want to share some articles from news site like bbc or cnn.I want to give a link in facebook from my application.
RBADS
+3  A: 

Try this :

findViewById(R.id.btnEnvoyer).setOnClickListener(
            new Button.OnClickListener() {
                public void onClick(View v) {
                    Intent sendMailIntent = new Intent(Intent.ACTION_SEND); 
                    sendMailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.Share_Mail_Subject));
                    sendMailIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.Share_Mail_Text)); 
                    sendMailIntent.setType("text/plain");

                    startActivity(Intent.createChooser(sendMailIntent, "Email / SMS / Tweet ?"));
                }
            }
    );

works just fine in my latest app if you want to test it : Comis Strips in Brussels

=> Hit [Menu], then [Share], then the button [Send Email / SMS / Tweet]=R.id.btnEnvoyer in my layout file to see the alternatives the user can choose from ...

Hope this helps you a bit ...

H.

Hubert
Thank you hubert, but can you please kindly write me how to do share feature like in facebook and twittter?.I try your code but it shows only mail application, but i want to share feature like in facebook or twitter just like your application.Again thanks
RBADS
that's because you have no Twitter or Facebook app installed on your phone, isn't it ? otherwise by default, the application would suggest these apps (in fact any app that's able to handle the Intent.ACTION_SEND). That's what the Intent.createChooser does : pop up the list of apps able to handle the Intent ... I haven't tested with Facebook honestly but it works great on Twitter.
Hubert
Maybe you tested on the emulator only (where you don't have the Twitter or Facebook app installed) ? Try it on a real phone, should work !
Hubert
okay thanks, but i have seen in android phone built in menu option in gallery page.When we hit menu in gallery page, share option comes automatically with list like facebook, gmail, twitter etc.Is it possible to use same code in our application?
RBADS
yeah, it comes.Sorry, i was trying in emulator.But when i ran code to android phones it came 'menu' what i want.Thank you once again
RBADS
goot to know that, have fun sharing on twitter then !
Hubert
Sure...have fun...thanks a lot
RBADS