如何从普通java类重定向到其他扩展android活动的java类?

如何从普通java类重定向到其他扩展android活动的java类?,java,android,Java,Android,如何从普通java类重定向到其他java类,通过放置一些数据扩展android中的活动 启动另一个活动类 Intent i = new Intent(this, ActivityTwo.class);//this your current class startActivity(i); 在类1中传递值 Intent i = new Intent(this, ActivityTwo.class); i.putExtra("Value1", "This value one for Activit

如何从普通java类重定向到其他java类,通过放置一些数据扩展android中的活动

启动另一个活动类

Intent i = new Intent(this, ActivityTwo.class);//this your current class
startActivity(i); 
在类1中传递值

Intent i = new Intent(this, ActivityTwo.class);
i.putExtra("Value1", "This value one for ActivityTwo ");
i.putExtra("Value2", "This value two ActivityTwo"); 
从ActivityTwo.class获取值

Bundle extras = getIntent().getExtras();
if (extras == null) {
  return;
}
// get data via the key
String value1 = extras.getString(Intent.EXTRA_TEXT);
if (value1 != null) {
  // do something with the data
} 

为什么这个问题被否决了?最好改进这个问题,或者至少评论一下你为什么投反对票。谢谢mek,如果你有必要,请做一些必要的事情answer@ChetakBhimani您可以使用意图这是您期望的吗?@Chetak我认为您在普通类中的方法必须接受上下文作为参数
public void navigatorMethod(Context-Context){…}
谢谢mak我明白你的意思了我必须通过上下文,已经完成了。谢谢