Is it possible to access resources in another APK without using content providers?

后端 未结 3 1590
难免孤独
难免孤独 2020-12-13 00:49

I thought that it is impossible to access resources contained in other APK unless content providers are used. However, I stumbled upon an app called Better Keyboard. It uses

3条回答
  •  执念已碎
    2020-12-13 01:28

    Try this

     PathClassLoader loader = 
     new PathClassLoader ("/data/app/com.skin.apk", null,PathClassLoader.getSystemClassLoader());
     InputStream f = loader.getResourceAsStream("res/drawable/icon.png");
     Bitmap bitmap=BitmapFactory.decodeStream(f);
     BitmapDrawable b=new BitmapDrawable(bitmap);
     mButton.setBackgroundDrawable(b);
    

提交回复
热议问题