Android 安卓手机短信应用程序显示发件人';s位置
我是一个机器人新手。我为一个非常原始的问题表示歉意。 我打算为短信开发一个android应用程序,这样当接收者收到短信时,发送者的物理位置也会自动显示(使用发送者的GPS)可能是Lat-Long格式。 我的问题是,如何解决这个问题?Android 安卓手机短信应用程序显示发件人';s位置,android,eclipse,Android,Eclipse,我是一个机器人新手。我为一个非常原始的问题表示歉意。 我打算为短信开发一个android应用程序,这样当接收者收到短信时,发送者的物理位置也会自动显示(使用发送者的GPS)可能是Lat-Long格式。 我的问题是,如何解决这个问题? 提前感谢你。我想。。获取发送者的位置完全取决于发送者,即如果发送者决定透露其位置。。只有收件人才能获得他的位置。。所以您尝试创建的应用程序应位于发件人电话中。。。在这种情况下 创建一个带有文本字段和按钮的活动,以发送如下消息 class A extends Ac
提前感谢你。我想。。获取发送者的位置完全取决于发送者,即如果发送者决定透露其位置。。只有收件人才能获得他的位置。。所以您尝试创建的应用程序应位于发件人电话中。。。在这种情况下 创建一个带有文本字段和按钮的活动,以发送如下消息
class A extends Activity
{
String s;
Oncreate()
{
editText = (EditText) findViewById(R.id.message);
sendBtn = (Button)findViewById(R.id.send);
sendBtn .setonclickListener(new OnClickListener(){
public void Onclick(){
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
MINIMUM_TIME_BETWEEN_UPDATES,
MINIMUM_DISTANCE_CHANGE_FOR_UPDATES,
new MyLocationListener()
);
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null) {
clat=location.getLatitude();
clon=location.getLongitude();
}
s=editText.getText().toString()+"lat"+clat+"long"+clong
PendingIntent pi = PendingIntent.getActivity(this, 0,
new Intent(this, Object.class), 0);
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, s, pi, null);
}
});
}
如何解决第一个参数中的错误,即“this” …请您解释一下代码中没有的“new MyLocationListener()”?当您需要更新时,您需要一个位置侦听器。。但是我们不需要任何更新。。只想知道现在的位置。。所以不需要locationlistener…所以在语句locationManager.requestLocationUpdates(locationManager.GPS\u提供程序,更新之间的最短时间,更新的最短距离,新MyLocationListener())中…我可以用“null”代替新的MyLocationListener()吗?
if (ActivityCompat.checkSelfPermission(**this**, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(**this**, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
{
}