简体   繁体   English

当活动屏幕首次在 Android Studio 上加载时,如何在隐藏背景中发送带有当前位置数据的 SMS 文本消息?

[英]How do I send a SMS text message in the hidden background with current location data when the activity screen first loads on Android Studio?

I need to make an activity send a text message when it first loads on Android Studio.我需要让活动在 Android Studio 上首次加载时发送一条短信。 It's for a mobile safety app that automatically sends your location data to the police via SMS when the app first loads.这是一款移动安全应用程序,当应用程序首次加载时,它会通过短信自动将您的位置数据发送给警方。

I'm trying the onStart method.我正在尝试 onStart 方法。

@Override
protected void onStart()
{   

super.onStart();
}

How can I do it or is there a better way?我该怎么做或者有更好的方法?

You cannot send a text message without getting user permission and the same applies for assessing the location未经用户许可,您不能发送短信,这同样适用于评估位置

Assuming that you had taken permission from USER and location is on假设您已获得 USER 的许可并且位置已开启

for sending the message here这里发送消息

and for accessing location on background here and here以及在此处此处访问背景位置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM