android分享功能的實現


  經常看到一些軟件有一些共享的按鈕,點擊這個按鈕,就會出現一大推你安裝過軟件列表(據說是注冊過什么東西的),比如:人人,開心,郵件等。其實實現非常簡單:

  

Intent intent=new Intent(Intent.ACTION_SEND);   
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT,data.get(mPosition).getTitle());
intent.putExtra(Intent.EXTRA_TEXT, data.get(mPosition).getText());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(Intent.createChooser(intent, "分享"));

  但是以前有個問題,當類型設置為:intent.setType("text/plain")時候,騰訊微薄,開心不會出現在分享的列表里面,下面是網上反編譯騰訊微薄的代碼(懶得反編譯了):

<activity android:name=".activity.MicroBlogInput" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation" android:windowSoftInputMode="stateAlwaysVisible|adjustResize">
<intent-filter android:label="@string/albums_sendbyWBlog">
<action android:name="android.intent.action.SEND" />
<data android:mimeType="image/*" />
         <
category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

  但是騰訊是乎該過來了,按照:intent.setType("text/plain")點擊分享按鈕,分享列表中會出現騰訊微薄,並且測試結果為:騰訊微薄,人人,gmail客戶端都能夠分享成功。

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM