• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps cannot find symbol: method startActivity

Alramo

Lurker


Hello,

I am developing an application in order to connect to Google Navigator by the following code..



public static void Call_GoogleMapsNavigation(int longitud,int latitud)

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;

{
Intent i = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("google.navigation:q=" +latitud+ ","+longitud+""));
Context.startActivity(i);
}


... but I get the following error:


Error returned:
GWDCPSET_GlobalProcedures_MobileDevice.java:1223: cannot find symbol
symbol : method startActivity(android.content.Intent)
location: class antay.cfsatv30.wdgen.GWDCPSET_GlobalProcedures_MobileDevice
startActivity(i);
^




I can not find the solution to the problem ...

:confused:
Thank you very much,
</SPAN>
 
startActivity is not a static method, and thus must be accessed from an instance of Context. Provided thr class that contains the method you posted is a subclass of Activity, you can simple remove the "Context." from your startActivity() call and just use startActivity(i). You could also use this.startActivity(i) if you wish.
 
startActivity is not a static method, and thus must be accessed from an instance of Context. Provided thr class that contains the method you posted is a subclass of Activity, you can simple remove the "Context." from your startActivity() call and just use startActivity(i). You could also use this.startActivity(i) if you wish.

Thanks jonbonazza,

Removing "Context." from start Activity, I'm getting the same error...

public static void Call_GoogleMapsNavigation(int longitud,int latitud)
import android.app.Activity;
import
android.content.Context;
import
android.content.Intent;
import
android.net.Uri;
{
Intent i = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("google.navigation:q=" +latitud+ ","+longitud+""));
startActivity(i);
}


And using .....
this.
startActivity(i);

Error returned:
src\antay\cfsatv30\wdgen\GWDCPSET_GlobalProcedures_MobileDevice.java:1222: cannot find symbol
symbol : method startActivity(android.content.Intent)
location: class antay.cfsatv30.wdgen.GWDCPSET_GlobalProcedures_MobileDevice
startActivity(i);
^


Error returned:
src\antay\cfsatv30\wdgen\GWDCPSET_GlobalProcedures_MobileDevice.java:1222: non-static variable this cannot be referenced from a static context
this.startActivity(i);
^
src\antay\cfsatv30\wdgen\GWDCPSET_GlobalProcedures_MobileDevice.java:1222: cannot find symbol
symbol : method startActivity(android.content.Intent)
location: class antay.cfsatv30.wdgen.GWDCPSET_GlobalProcedures_MobileDevice
this.startActivity(i);
^
2 errors

Any idea?

Thanks!!
 
Back
Top Bottom