2012-09-15 78 views
-2

在android中,以下代码是否有区别?如何使用Intent构造函数?

  1. new Intent(this,MyOtherActivity.class);
  2. 新意图(Context.this,MyOtherActivity.class);
  3. 新意图(getApplicationContext(),MyOtherActivity.class);

请details.example代码解释也表示赞赏。

在此先感谢。

+0

*您应该阅读* [文件和指南](http://developer.android.com/guide/components/intents-filters.html) – adatapost

+0

为什么你要问? –

回答

1
1> new Intent(this, MyOtherActivity.class); here this means the context of your current 
    activity 
    3> new Intent(getApplicationContext(), MyOtherActivity.class); here getApplicationContext() means the context of your application. 
+0

好吧,当我使用这个,上下文或应用程序上下文。 – Selva

+0

对于长时间运行的过程是怎样的服务,使用应用程序上下文 – Rajendra

+0

感谢rajuendra – Selva