启动意图和SetClassName一个活动 [英] Starting an Activity with Intent and SetClassName

查看:99
本文介绍了启动意图和SetClassName一个活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的code移动到另一个活动:

I am using the following code to move to another Activity :

Intent intent = new Intent();  
String test = "Navigate";  
intent.setClassName(this.context,test);  
intent.putExtra("params", params);  
((Activity) context).startActivity(intent);  

不过,我无法启动浏览活动。无异常。 出于同样的,如下因素code正常工作:

But I am unable to start the Navigate Activity. No exception is thrown. For the same, the folowing code works fine:

Intent intent = new Intent(this.context,Navigate.class);  
intent.putExtra("params", params); 
((Activity) context).startActivity(intent);    

请告诉我,如果任何变通。

Please tell me if any work around.

推荐答案

您需要完整的类名,包括包:

You need the full classname, including the package:

String test = "your.package.here.Navigate";

。(在清单中定义的活动,但你可以用 Navigate.class 我假设你已经做到了这一点开始吧)

(And the Activity defined in the Manifest, but as you can start it with Navigate.class I assume you have already done this).

这篇关于启动意图和SetClassName一个活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆