進階 Android 代碼管理工具設定
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
若要擴充 Google 代碼管理工具的功能,您可以新增函式呼叫變數和函式呼叫代碼。函式呼叫變數可讓您擷取呼叫預先註冊函式時回傳的值。函式呼叫代碼可讓您執行預先註冊函式 (例如,在代碼管理工具中的代碼範本目前不支援的額外評估和再行銷工具中觸發命中)。
如何使用函式呼叫新增自訂標記或自訂變數:
實作可擴充 com.google.android.gms.tagmanager.CustomTagProvider
或 com.google.android.gms.tagmanager.CustomVariableProvider
的類別:
import android.support.annotation.Keep;
import java.util.Map;
@Keep
public class HighScoreProvider implements com.google.android.gms.tagmanager.CustomVariableProvider {
@Override
public String getValue(Map<String, Object> map) {
synchronized (HighScoreProvider.class) {
return ((Long)sHighScore).toString();
}
}
private static long sHighScore = 0;
public static void recordScore(long score) {
synchronized (HighScoreProvider.class) {
sHighScore = Math.max(score, sHighScore);
}
}
}
如果您使用 ProGuard,請確認類別名稱和方法未經過模糊處理。請使用 Keep 註解來指定這項設定。
在 Google 代碼管理工具的網頁介面中,使用完整類別名稱來設定代碼和變數:
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2023-10-27 (世界標準時間)。
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"缺少我需要的資訊"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"過於複雜/步驟過多"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"過時"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"翻譯問題"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"示例/程式碼問題"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"其他"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"容易理解"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"確實解決了我的問題"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"其他"
}]
{
"last_modified": "上次更新時間:2023-10-27 (世界標準時間)。",
"state": ""
}