Android應用中實現系統「分享」介面

2021-08-02 14:31:52 字數 1371 閱讀 6613

第一步:在manifest.xml進行配置,比普通的activity中多增加乙個intent過濾器

android:name="com.example.share.mainactivity"  

public class mainactivity extends activity   

}  /** 

* 通過uri獲取檔案在本地儲存的真實路徑 

*/  

private string getrealpathfromuri(uri contenturi) ;  

cursor cursor=getcontentresolver().query(contenturi, proj, null, null, null);  

if(cursor.movetonext())  

cursor.close();  

return null;  

}  }  

如果需要分享多個檔案怎麼辦?

答:修改 manifest.xml中activity中intent中action的android:name屬性

效果圖如下:

我參考的部落格:

android 常用 mimetype 表

一、mime type描述

多用途網際網路郵件擴充套件mimemultipurpose internet mail extensions)是乙個網際網路標準

,它擴充套件了電子郵件

標準,使其能夠支援非ascii

字元、二進位制

格式附件等多種格式的郵件訊息。

內容型別(content-type),這個頭部領域用於指定訊息的型別。一般以下面的形式出現。[type]/[subtype]

type有下面的形式。

subtype用於指定type的詳細形式。content-type/subtype配對的集合和與此相關的引數,將隨著時間而增長。為了確保這些值在乙個有序而且公開的狀態下開發,mime使用internet assigned numbers authority (iana)作為中心的註冊機制來管理這些值。常用的subtype值如下所示:

二、常用mime type表

**:

Android系統分享

android系統分享目前無法同時分享文字和 1 建立intent,action為intent.action send intent shareintent new intent intent.action send shareintent.setflags intent.flag activity...

Android新建系統分割槽

平台 rk3368 系統 android8.1 上為了保留一些檔案在系統公升級和燒錄後不被擦除,因此新建了個不被擦除的分割槽,在此記錄下方法。分割槽表檔案路徑 device rockchip rk3368 parameter.txt,其中mypartition是我建立的分割槽,格式為 大小 位址 分...

Android實現獲取系統應用列表

android系統為我們提供了很多服務管理的類,包括activitymanager powermanager 電源管理 audiomanager 音訊管理 等。除此之外,還提供了乙個packagemanger管理類,它的主要職責是管理應用程式包。通過它,我們就可以獲取應用程式資訊。packagema...