1
我是新的android和我嘗試在兩個活動之間傳輸數據。 Eclipse告訴我,行:android新的意圖錯誤
Intent i = new Intent(this, PostDataActivity.class);
構造函數Intent是未定義的。我能做什麼?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btnShowLocation = (Button) findViewById(R.id.ansehen);
// show location button click event
btnShowLocation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// create class object
gps = new GpsData(StartActivity.this);
// check if GPS enabled
if(gps.canGetLocation()){
double latitude = gps.getLatitude();
double longitude = gps.getLongitude();
String mlat = String.valueOf(latitude);
// \n is for new line
Intent i = new Intent(this, PostDataActivity.class);
i.putExtra("Value1", "This value one for ActivityTwo ");
嘗試'Your_activityName.this'不是僅僅'this'並有你加入'StartActivity(我);' – juned