Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

安卓8以上后台定位功能 #14

Closed
JeasonLaung opened this issue Nov 26, 2019 · 5 comments
Closed

安卓8以上后台定位功能 #14

JeasonLaung opened this issue Nov 26, 2019 · 5 comments
Labels
enhancement New feature or request stale 长时间没有响应

Comments

@JeasonLaung
Copy link

功能描述
安卓8以上后台定位功能
Native端对应字段/方法
AMapLocationClient.disableBackgroundLocation(boolean removeNotification)
AMapLocationClient.enableBackgroundLocation(int notificationId, Notification notification)
源码的amap的location sdk示例有(在/app/src/main/java/com/amap/location/demo/Location_BackGround_Activity.java中)
image
参考文档:http://amappc.cn-hangzhou.oss-pub.aliyun-inc.com/lbs/static/unzip/Android_Location_Doc/index.html

谢谢大佬!!

@yohom
Copy link
Member

yohom commented Nov 26, 2019

Notification从哪里拿?

@JeasonLaung
Copy link
Author

JeasonLaung commented Nov 26, 2019

直接用app的通知即可

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.graphics.Color;

函数代码 https://lbs.amap.com/api/android-location-sdk/guide/utilities/permision_8

Utils.getAppName函数为这个
/**
* 获取app的名称
* @param context
* @return
*/
public static String getAppName(Context context) {
String appName = "";
try {
PackageManager packageManager = context.getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(
context.getPackageName(), 0);
int labelRes = packageInfo.applicationInfo.labelRes;
appName = context.getResources().getString(labelRes);
} catch (Throwable e) {
e.printStackTrace();
}
return appName;
}

@yohom
Copy link
Member

yohom commented Nov 26, 2019

你这个基本上都是调用的系统API啊,建议你还是fork一份去自己在原生代码里加吧

@JeasonLaung
Copy link
Author

主要是没写过安卓机呀😅,复制进去改也全是报错,我在试试吧,谢谢大佬

@yohom yohom added the enhancement New feature or request label Dec 3, 2019
@stale
Copy link

stale bot commented Mar 6, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale 长时间没有响应 label Mar 6, 2020
@stale stale bot closed this as completed Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale 长时间没有响应
Projects
None yet
Development

No branches or pull requests

2 participants