Giter Club home page Giter Club logo

Comments (4)

xiangtailiang avatar xiangtailiang commented on May 26, 2024 1

Q:base Apk中通过getResources().getIdentifier访问插件资源为什么访问不了?

A:

getResources().getIdentifier("hello_world","string", getPackageName() + "." + "${插件名}");

from qigsaw.

archko avatar archko commented on May 26, 2024

Q:base Apk中通过getResources().getIdentifier访问插件资源为什么访问不了?

A:

getResources().getIdentifier("hello_world","string", getPackageName() + "." + "${插件名}");

我想实现,宿主动态代理插件的Activity,这样插件可以不注册Activity。
使用dynamic-load-apk的代码。我看到wiki,qigaw是没有这样的功能的,所以我想试试实现这样的功能。
结果:
一种是:插件里面的Activity加载成功了,布局没有加载成,白屏。
一种是:插件Activity启动了,页面正常,对话框显示不正常。

DLProxyFragmentActivity覆盖了:
@OverRide
public Resources getResources() {
return impl.getResources() == null ? super.getResources() : impl.getResources();
}
在dynamic-load-apk中,它是使用apk加载,创建Resources,而我这里是通过context = ctx.createPackageContext(ctx.getPackageName(), 0);
resources = context.getResources();这样创建,然后传入。
对话框就是示例中的那个简单的;小米6出现:Binary XML file line #44: Error inflating class com.android.internal.widget.DialogTitle。有些手机正常显示。
白屏的是插件里未注册的Activity执行到setcontentview就错误了,feature日志是加载成功的。
getResources()是否与加载器有关。
另外,我想问一下。qigsaw的项目上,实现这种 动态的Activity是不是可行的。

from qigsaw.

wys619 avatar wys619 commented on May 26, 2024

在activity的基类重写getResource方法,然后加上:Qigsaw.onApplicationGetResources(resources);试试;
类似这样:

override fun getResources(): Resources {
    val resources = super.getResources()
    Qigsaw.onApplicationGetResources(resources)
    return resources
}

from qigsaw.

PengZeHai avatar PengZeHai commented on May 26, 2024

Q:base Apk中通过getResources().getIdentifier访问插件资源为什么访问不了?

A:

getResources().getIdentifier("hello_world","string", getPackageName() + "." + "${插件名}");

很好奇为什么可以通过getPackageName() + "." + "${插件名}" 方式获取到插件的id

from qigsaw.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.