我工作的一个Android应用程序开发和我陷进了这一点:传递位置数据到另一个活动的Android
我有2个活动: 第一个叫CurrentLoc,它让我的当前位置并获得位置后,我点击一个按钮,带我到活动号码2,称为短信。
什么,我需要做的是,我想通过我的第一个活动已收到了第二个活动当我点击按钮的位置数据...
在此先感谢大家。 ..
这里是我的第一个活动代码:
public class Tester2Activity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
startService(new Intent(Tester2Activity.this,SS.class));
LocationManager mlocManager = (LocationManager)getSystemService (Context.LOCATION_SERVICE);
LocationListener mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, mlocListener);
Button button1 = (Button) findViewById(R.id.widget30);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent hg = new Intent(Tester2Activity.this, Sms.class);
startActivity(hg);
}
});
public class MyLocationListener implements LocationListener
{
@Override
public void onLocationChanged(Location loc)
{
loc.getLatitude();
loc.getLongitude();
//This is what i want to pass to the other activity when i click on the button
}
@Override
public void onProviderDisabled(String provider)
{
}
@Override
public void onProviderEnabled(String provider)
{
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras)
{
}
}
}
你有没有解决问题了吗? –