454
技術社區[雲棲]
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