2014-10-28 10 views
7

मेरे ऐप में मैं फेसबुक में हम "share dialog" या पोस्ट बंडलएंड्रॉइड में ट्विटर के माध्यम से लिंक कैसे साझा करें?

Request request = new Request(Session.getActiveSession(), "me/feed", bundle, HttpMethod.POST, 
     new Request.Callback(){ 
       @Override 
       public void onCompleted(Response response) { 
        ... 
       } 
      }); 

की तरह की तरह कुछ मिल गया फेसबुक और ट्विटर के माध्यम से प्रोमो साइट के लिए लिंक साझा करने की जरूरत है, लेकिन वहाँ एंड्रॉयड (trully मैं twitter4j का उपयोग करें) के लिए कोई चहचहाना एसडीके हैं और बंडल

पोस्ट करने का कोई तरीका नहीं है तो ट्विटर के माध्यम से लिंक कैसे ट्वीट करें?

उत्तर

1

आप इस तरह के इरादे के माध्यम से यह कर सकते हैं:

Intent sendIntent = new Intent(); 
sendIntent.setAction(Intent.ACTION_SEND); 
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send."); 
sendIntent.setType("text/plain"); 
startActivity(sendIntent); 

यह पहले से ही इंस्टॉल किए गए एप्लिकेशन कि आशय जवाब कर सकते हैं जीमेल, फेसबुक और ट्विटर जैसी ..., के साथ एक सूची खुलेगी। इसके अलावा http://developer.android.com/training/sharing/send.html

, अगर आप सीधे चहचहाना कॉल करना चाहते हैं और चयन करने के लिए नहीं करना चाहते, this answer

2

पर एक नजर है आप की तरह के लिंक के साथ पाठ भेजते हैं ":

आप यहां और जानकारी प्राप्त कर सकते हैं यहां हमारा लिंक है: http://stackoverflow.com "- ट्विटर इसे समझ जाएगा और आपके लिंक से जानकारी प्राप्त करेगा और इसे दिखाएगा - जैसा कि मैं समझता हूं कि आपको ट्विटर फ़ीड में अपना मान्यता प्राप्त लिंक देखना होगा। लिंक पोस्ट करने के लिए आप @Adrian Sicaru तरह आशय बनाने या twitter4j साथ asynctask का उपयोग कर के रूप में आप का उल्लेख अपने स्वयं के कस्टम संवाद बना सकते हैं:

@Override 
protected Bundle doInBackground(Bundle... params) { 
    Bundle args = params[0]; 
    Bundle result = new Bundle(); 

    String paramMessage = args.getString(MESSAGE); 
    String paramLink = args.getString(LINK); 

    ConfigurationBuilder builder = new ConfigurationBuilder(); 
    builder.setOAuthConsumerKey("your ConsumerKey"); 
    builder.setOAuthConsumerSecret("your ConsumerSecret"); 

    String accessToken = "your Token"; 
    String accessTokenSecret = "your Secret"; 

    TwitterFactory factory = new TwitterFactory(builder.build()); 
    mTwitter = factory.getInstance(new AccessToken(accessToken, accessTokenSecret)); 
    try { 
     StatusUpdate status = new StatusUpdate(paramMessage); 

     if (paramLink != null) { 
      status = new StatusUpdate(paramMessage + " " + paramLink); 
     } 
     mTwitter.updateStatus(status); 
    } catch (TwitterException e) { 
     result.putString(RESULT_ERROR, e.getMessage()); 
    } 
    return result; 
} 
1

@TribblerWare की तरह सिर्फ ट्वीट में कड़ी लिखने के जवाब दिए और चहचहाना यह स्वीकार किया।

वैसे, आप इस के लिए ASNE library उपयोग कर सकते हैं - बस उपयोगकर्ता को प्राधिकृत और पैरामीटर के रूप में requestPostLink का उपयोग बंडल के साथ

Bundle postParams = new Bundle(); 
postParams.putString(SocialNetwork.BUNDLE_LINK, link); 
socialNetwork.requestPostLink(postParams, message, postingComplete); 

अधिक विस्तृत आप tutorial

में देख सकते हैं
संबंधित मुद्दे