1)你可以嘗試得到最後的知道,從GPS或網絡提供商
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
Location gpsLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
Location networkLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
2位),您可以使用這個代碼
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("sms:" + phoneNumber));
intent.putExtra("sms_body", message);
startActivity(intent);
或查看答案How can I send sms messages in the BACKGROUND using Android?
不要忘記添加所需的權限