gpt4 book ai didi

java - 获取/发送短信时如何获取GPS坐标?

转载 作者:行者123 更新时间:2023-11-29 20:20:47 26 4
gpt4 key购买 nike

<分区>

我正在制作短信记录器。我已经获得了数据、短信正文等信息。但我还想在从我的设备发送短信的位置添加 GPS 坐标,并与传入的短信相同。

我如何获取短信信息:

public List<String> getInboundSMSCaptured() {
EnterpriseDeviceManager edm = (EnterpriseDeviceManager) getSystemService(EnterpriseDeviceManager.ENTERPRISE_POLICY_SERVICE);
DeviceInventory deviceInventoryPolicy = edm.getDeviceInventory();

List<String> list = new ArrayList<String>();
List<String> outlist = new ArrayList<String>();

try {
deviceInventoryPolicy.enableSMSCapture(true);
// The device has likely logged some SMS messages at some point
// after
// enabling the policy.
list = deviceInventoryPolicy.getInboundSMSCaptured();

String separator = ";";

TelephonyManager telemamanger = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
// String getSimSerialNumber = telemamanger.getSimSerialNumber(); //serial
// String imei = telemamanger.getDeviceId(); // imei
String OperatorName = telemamanger.getSimOperatorName(); // operator

for (String log : list) {
String character = "$";
String newlog = log + character;
newlog = newlog.replace("\n", "").replace("\r", "");
outlist.add(newData(getPieceOfStr("TimeStamp:", " - ", log))
+ separator + "In" + separator
+ getPieceOfStr("From:", " - ", log) + separator
+ OperatorName + separator + "\ufeff"
+ getPieceOfStr("Body:", LastElement(newlog), newlog)
+ separator);
}

} catch (SecurityException e) {
Log.w(TAG, "SecurityException: " + e);
}
return outlist;
}

然后我在设备上创建 CSV 文件:

public void writeAllSMSs(List<String> InSMSs, List<String> OutSMSs) {

List<String> AllSMSs_list = new ArrayList<String>();

InSMSs = getInboundSMSCaptured();
OutSMSs = getOutboundSMSCaptured();

TelephonyManager telemamanger = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String imei = telemamanger.getDeviceId();

// separator for excel
String separator = ";";

AllSMSs_list = InSMSs;

AllSMSs_list.addAll(OutSMSs);

// sort from old to new calls
Collections.sort(AllSMSs_list);

// add info on top of file
AllSMSs_list.add(0, "Time" + separator + "Status" + separator
+ "SMS Number" + separator + "Operator" + separator + "Body"
+ separator + "Latitude" + separator + "Longitude");

try {
FileOutputStream fileout = openFileOutput("SMS's.csv",
MODE_MULTI_PROCESS);
OutputStreamWriter outputWriter = new OutputStreamWriter(fileout);

for (int i = 0; i < AllSMSs_list.size(); i++) {
outputWriter.write(AllSMSs_list.get(i) + "\n");
}

Collections.reverse(AllSMSs_list);

outputWriter.write("\n\nFile created: " + currentData());

outputWriter.flush();
outputWriter.close();

// display file saved message
Toast.makeText(getBaseContext(), "File saved successfully!",
Toast.LENGTH_SHORT).show();

copyFile("/data/data/com.example.samsungmdm/files/SMS's.csv",
// for android /0/ for knox /100/
"/storage/emulated/0/KNOX_Logs/"
// "/storage/emulated/100/KNOX_Logs/"
+ imei + " SMS's.csv");

} catch (Exception e) {
e.printStackTrace();
}
}

谢谢

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com