在webview url中的Android ID
问题描述:
我有一个android应用程序与webview,我想发送唯一的设备ID到PHP文件。如何在webview url上添加android_id(或设备ID,应用程序ID)?在webview url中的Android ID
事情是这样的:
webview launchUrl = "https://www.exampledomain.com/myphp.php?androidid=ANDROID_ID";
ANDROID_ID= xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
答
我用我的Android应用科尔多瓦+网页视图+ Onesignal。我现在有这样的代码:
private static String uniqueID = UUID.randomUUID().toString();
private static final String PREFS_GT_PLAYER_ID = "GT_PLAYER_ID";
public synchronized static String id(Context context) {
if (uniqueID == null) {
SharedPreferences sharedPrefs = context.getSharedPreferences(PREFS_GT_PLAYER_ID, Context.MODE_PRIVATE);
uniqueID = sharedPrefs.getString(PREFS_GT_PLAYER_ID, null);
if (uniqueID == null) {
uniqueID = UUID.randomUUID().toString();
SharedPreferences.Editor editor = sharedPrefs.edit();
editor.putString(PREFS_GT_PLAYER_ID, uniqueID);
editor.commit();
}
}
return uniqueID;
}
private void setStartUrl(String src) {
Pattern schemeRegex = Pattern.compile("^[a-z-]+://");
Matcher matcher = schemeRegex.matcher(src);
if (matcher.find()) {
launchUrl = src;
} else {
if (src.charAt(0) == '/') {
src = src.substring(1);
}
launchUrl = "https://www.exampledomain.com/myphp.php?androidid=" + uniqueID;
}
}
uniqueID是随机生成的,但我想从onesignal生成player_id。 This is a print screen from my onesignal account
您的问题是ambigous,你想要添加Android ID到PHP文件或Java文件?什么是Android ID?来自xml的属性ID,还是来自设备的IP值或什么?如果在PHP刚刚添加了全局$ _GET ['andoidid'] = $ value; – user8455694
ANDROID_ID = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx webview launchUrl =“https://www.exampledomain.com/myphp.php?androidid="+ANDROID_ID; 使用launchUrl concat ANDROID_ID – Sanil
我需要设备ID(UUID)通过在web视图中发送becouse我需要在PHP中注册每个设备以基于每个设备ID发送不同的通知。例如:发票通知,服务激活停用etc.Simply我需要知道在PHP是什么是每个设备的目标他们的身份和发送通知。 –