由于GDPR,我需要检查用户位置是否用户来自欧盟.直到现在我找到了这些解决方案 -
1)使用电话的语言配置获取国家(如果用户使用英语美国版本可能会误导,即使他可能来自其他国家/地区).
String locale = context.getResources().getConfiguration().locale.getCountry();
Run Code Online (Sandbox Code Playgroud)
2)使用GPS获取位置(需要位置Corse权限,我不想添加,特别是因为Android 6.0+运行时权限).
private void getCountryCode(final Location location) {
Helper.log(TAG, "getCountryCode");
AsyncTask<Void, Void, String> countryCodeTask = new AsyncTask<Void, Void, String>() {
final float latitude = (float) location.getLatitude();
final float longitude = (float) location.getLongitude();
// Helper.log(TAG, "latitude: " +latitude);
List<Address> addresses = null;
Geocoder gcd = new Geocoder(mContext);
String code = null;
@Override
protected String doInBackground(Void... params) {
try {
addresses = gcd.getFromLocation(latitude, longitude, 1);
code = …
Run Code Online (Sandbox Code Playgroud) 我试图找出Ad Junk present(由其他应用程序的AD SDK下载的文件).
这是我迄今为止所能找到的 -
我正在加载设备中所有文件的列表,并检查它们并将它们分组
if (file.getPath().toLowerCase().endsWith(".temp") )
{
//Temp Files found
}
else if (file.getName().endsWith(".apk") && file.canWrite())
{
//Apk Files found
}
Run Code Online (Sandbox Code Playgroud)
还有许多其他清洁工可以找到设备中存在的垃圾文件.即使我试图实现同样的目标.任何人都可以帮我确定文件是否是AD垃圾文件?
我正在运行 aJobIntentService
以在后台执行任务。使用的原因JobIntentService
是这样用户可以在操作发生时最小化屏幕,即使 Android 操作系统破坏了 ActivityJobIntentService
仍将继续运行,如果用户回来,他可以更新结果。
但是我有一个案例,假设用户自己关闭了应用程序,然后我也想停止应用程序JobIntentService
。
JobIntentService
当用户自己关闭应用程序时,有什么方法可以通知。
任何帮助将不胜感激。
编辑:我尝试使用onTaskRemoved
它是没有用的,因为我的测试设备不会调用它(我相信许多其他设备也不会调用它)。此外,当应用程序从最近的列表中删除时,该服务会自动停止,但在再次打开应用程序时再次重新启动,这是我不想要的。
我正在使用JobIntentService
执行某些任务,在任务结束后我发送一个广播,我的活动之一也会监听该广播。
假设在 Android 操作系统关闭 Activity 以释放一些内存的情况下,如果从应用程序发送广播,JobIntentService
是否OnCreate
也会调用应用程序?
java service android android-broadcast android-application-class
android ×4
java ×2
android-gps ×1
file ×1
geolocation ×1
location ×1
privacy ×1
service ×1
storage ×1