2017-03-06 88 views
-1

我試圖使用GoogleMapsActivity。在這種情況下,當前位置接近正確點時,活動必須啓動其他活動。我看了很多文章,我發現這一點:在googlemapsactivity中獲取上下文

Intent intent = new Intent("fto.behapp.Locations"); 
intent.putExtra("situations",Integer.parseInt(valid)); 
intent.putExtra("ring",true); 
intent.putExtra("type",1); 
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
intent.setClass(context, Locations.class); 
intent.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED + 
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD + 
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON + 
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); 
toast("inside"); 
startActivity(intent); 

但我沒有任何context設置意圖類,我不能使用this,任何人都有想法如何,我可以解決這一問題?

+1

活動**是**上下文 –

+0

使用'YourActivityClass.this'。 –

+0

是什麼?當我們的googlemap fragmen時,我怎麼稱呼它? – farshad

回答

0

如果您處於活動狀態,則可以使用getApplicationContext()。或者你可以使用getContext()如果你在片段。