如何从活动的包含类中启动意图

| 我正在寻找一种最佳方法,该方法是从不是Activity而是Activity类的一个包含对象的类中启动意图的。 例如活动类:
Class MainActivity extends ListActivty
{
...
TestLauncher tester;
}
我想从中开始意图的课程:
Class TestLauncher
{
   public TestLauncher ()
   {
      //Code to create an intent needs a Context
      //Intent i = new Intent(Context, class)

      //Code to start activity needs to be called with an Activity
      //Activity.StartActivity(i);
   }
}
在架构上做到这一点的最佳方法是什么?我应该将
MainActivity
作为参数传递给
TestLauncher
\的构造函数吗?还是有我不知道的更好的方法?     
已邀请:
        
Class TestLauncher
{
   public TestLauncher (Context c)
   {
      Intent i = new Intent(c, YourActivity.class)
      c.startActivity(i);
   }
}

TestLauncher ts=new TestLauncher(getApplicationContext());
    

要回复问题请先登录注册