我有一个与java中的动态代理有关的问题.
假设我有一个Foo用方法execute和类调用的接口FooImpl implements Foo.
当我创建代理时Foo,我有类似的东西:
Foo f = (Foo) Proxy.newProxyInstance(Foo.class.getClassLoader(),
new Class[] { Foo.class },
handler);
Run Code Online (Sandbox Code Playgroud)
假设我的调用处理程序如下所示:
public class FooHandler implements InvocationHandler {
public Object invoke(Object proxy, Method method, Object[] args) {
...
}
}
Run Code Online (Sandbox Code Playgroud)
如果我的调用代码看起来像
Foo proxyFoo = (Foo) Proxy.newInstance(Foo.getClass().getClassLoader(),
new Class[] { Foo.class },
new FooHandler());
proxyFoo.execute();
Run Code Online (Sandbox Code Playgroud)
如果代理可以execute从Foo界面拦截上述呼叫,那么它FooImpl可以在哪里播放?也许我正在以错误的方式查看动态代理.我想要的是能够execute从具体实现中捕获调用Foo,例如FooImpl.可以这样做吗?
非常感谢
我可以在不使用意图的情况下将字符串传递给Android中的另一个活动吗?我在意向附加项方面遇到麻烦...它们似乎并不总是有效!那么,还有其他方法吗?
我曾尝试过的意图:
String id = intent.getStringExtra("id");
String name = intent.getStringExtra("name");
Run Code Online (Sandbox Code Playgroud)
但是每次我开始活动时,它都会得到两种字符串。第一次与其他时间不同。我可以在不使用意图的情况下将其他活动传递给第二活动吗?
我有大量的字符串列表,我希望iteratoe在这个列表上.我想弄清楚哪个是迭代列表的最佳方法.我尝试过使用以下方法:
发电机表达: g = (x for x in list)
Itertools.chain: ch = itertools.chain(list)
对于列表迭代,是否有另一种方法,优于这两种方法?