閱讀454 返回首頁    go 技術社區[雲棲]


apk之間資源共享

apk之間可以相互讀取數據。

注意以下條件:

1.有同樣的簽名(app.keystoe)

2.在AndroidManifest.xml文件中配置的android:sharedUserId屬性值相同

3.兩個apk運行在同一個進程中.

主程序及讀取的apk中AndroidManifest.xml中配置

        android:sharedUserId="com.why.android"

訪問資源的方法

        Context mContext = this.createPackageContext("com.demo.android",Context.CONTEXT_IGNORE_SECURITY); 

        Drawable image = mContext.getResources().getDrawable(R.drawable.icon);

    Button mButton = (Button)findViewById(R.id.btn);

    mButton.setBackgroundDrawable(image);

最後更新:2017-04-02 15:32:47

  上一篇:go 【轉載——兩個很基礎的選舉算法】分布式係統進程的選舉
  下一篇:go ICADL2012- A Scalable, Adaptive, Self-management and Fault-tolerant Architecture for Digital Library