我如何从非活性类举杯?活性

2023-09-05 02:27:24 作者:你那么美,为你而醉

我有我使用得到在我的活动GPS数据的类。在构造函数中我将它传递活动的背景下:

I have a class that I am using to get GPS data within my activity. In the constructor I pass it the activity's context:

gpsFetcher = new GPSFetcher(this);

和在gpsFetcher I类有:

and in the gpsFetcher class I have:

this.context = c.getApplicationContext();

或只是

this.context = c;

然后我打电话吐司:

and then I call the toast with:

Toast.makeText(context, "sometext", Toast.LENGTH_LONG);

但它一直没有出现......有我丢失的东西?这可能吗?

But it never shows up... Is there something I'm missing? Is it possible?

谢谢!

推荐答案

你是不是忘记吐司#秀

Toast toast = Toast.makeText(context, "sometext", Toast.LENGTH_LONG);
toast.show();
 
精彩推荐
图片推荐