android.content.pm.ShortcutManager#reportShortcutUsed()源码实例Demo

下面列出了android.content.pm.ShortcutManager#reportShortcutUsed() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ShadowsocksRR   文件: QuickToggleShortcut.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String action = getIntent().getAction();

    if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) {
        setResult(Activity.RESULT_OK, new Intent()
                .putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(this, QuickToggleShortcut.class))
                .putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.quick_toggle))
                .putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
                        Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_launcher)));
        finish();
    } else {
        mServiceBoundContext.attachService();
        if (Build.VERSION.SDK_INT >= 25) {
            ShortcutManager service = getSystemService(ShortcutManager.class);
            if (service != null) {
                service.reportShortcutUsed("toggle");
            }
        }
    }
}
 
源代码2 项目: ShadowsocksRR   文件: ScannerActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_scanner);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(getTitle());
    toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_material);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            navigateUp();
        }
    });

    scannerView = (ZXingScannerView) findViewById(R.id.scanner);

    if (Build.VERSION.SDK_INT >= 25) {
        ShortcutManager service = getSystemService(ShortcutManager.class);
        if (service != null) {
            service.reportShortcutUsed("scan");
        }
    }
}
 
源代码3 项目: Maying   文件: QuickToggleShortcut.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String action = getIntent().getAction();

    if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) {
        setResult(Activity.RESULT_OK, new Intent()
                .putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(this, QuickToggleShortcut.class))
                .putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.quick_toggle))
                .putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
                        Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_launcher)));
        finish();
    } else {
        mServiceBoundContext.attachService();
        if (Build.VERSION.SDK_INT >= 25) {
            ShortcutManager service = getSystemService(ShortcutManager.class);
            if (service != null) {
                service.reportShortcutUsed("toggle");
            }
        }
    }
}
 
源代码4 项目: Maying   文件: ScannerActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_scanner);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(getTitle());
    toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_material);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            navigateUp();
        }
    });

    scannerView = (ZXingScannerView) findViewById(R.id.scanner);

    if (Build.VERSION.SDK_INT >= 25) {
        ShortcutManager service = getSystemService(ShortcutManager.class);
        if (service != null) {
            service.reportShortcutUsed("scan");
        }
    }
}
 
源代码5 项目: rcloneExplorer   文件: AppShortcutsHelper.java
public static void reportAppShortcutUsage(Context context, String remoteName) {
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.N_MR1) {
        return;
    }

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    Set<String> appShortcutIds = sharedPreferences.getStringSet(context.getString(R.string.shared_preferences_app_shortcuts), new HashSet<String>());

    String id = getUniqueIdFromString(remoteName);

    if (appShortcutIds.contains(id)) {
        ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
        if (shortcutManager == null) {
            return;
        }
        shortcutManager.reportShortcutUsed(id);
    }
}
 
源代码6 项目: GcmForMojo   文件: WechatContactsActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_wechat_contacts);
    //Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    //setSupportActionBar(toolbar);

    WechatFriendArrayList = MyApplication.getInstance().getWechatFriendArrayList();
    WechatFriendGroups = MyApplication.getInstance().getWechatFriendGroups();

    init();

    // Android 7.1 用于提升Shortcut启动性能
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
        ShortcutManager mShortcutManager = getSystemService(ShortcutManager.class);
        mShortcutManager.reportShortcutUsed("static_wechat_contacts");
    }

}
 
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_quick_switch);
    profilesAdapter = new ProfilesAdapter();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.quick_switch);

    RecyclerView profilesList = (RecyclerView) findViewById(R.id.profilesList);
    LinearLayoutManager lm = new LinearLayoutManager(this);
    profilesList.setLayoutManager(lm);
    profilesList.setItemAnimator(new DefaultItemAnimator());
    profilesList.setAdapter(profilesAdapter);
    if (app.profileId() >= 0) {
        int position = 0;
        List<Profile> profiles = profilesAdapter.profiles;
        for (int i = 0; i < profiles.size(); i++) {
            Profile profile = profiles.get(i);
            if (profile.id == app.profileId()) {
                position = i + 1;
                break;
            }
        }
        lm.scrollToPosition(position);
    }

    if (Build.VERSION.SDK_INT >= 25) {
        ShortcutManager service = getSystemService(ShortcutManager.class);
        if (service != null) {
            service.reportShortcutUsed("switch");
        }
    }
}
 
源代码8 项目: Maying   文件: ShadowsocksQuickSwitchActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_quick_switch);
    profilesAdapter = new ProfilesAdapter();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.quick_switch);

    RecyclerView profilesList = (RecyclerView) findViewById(R.id.profilesList);
    LinearLayoutManager lm = new LinearLayoutManager(this);
    profilesList.setLayoutManager(lm);
    profilesList.setItemAnimator(new DefaultItemAnimator());
    profilesList.setAdapter(profilesAdapter);
    if (ShadowsocksApplication.app.profileId() >= 0) {
        int position = 0;
        List<Profile> profiles = profilesAdapter.profiles;
        for (int i = 0; i < profiles.size(); i++) {
            Profile profile = profiles.get(i);
            if (profile.id == ShadowsocksApplication.app.profileId()) {
                position = i + 1;
                break;
            }
        }
        lm.scrollToPosition(position);
    }

    if (Build.VERSION.SDK_INT >= 25) {
        ShortcutManager service = getSystemService(ShortcutManager.class);
        if (service != null) {
            service.reportShortcutUsed("switch");
        }
    }
}
 
源代码9 项目: zapp   文件: ShortcutHelper.java
/**
 * Call to report a shortcut used.
 * You may call this using any api level.
 *
 * @param context   to access system services
 * @param channelId id of the channel that has been selected
 */
public static void reportShortcutUsageGuarded(Context context, String channelId) {
	if (areShortcutsSupported()) {
		ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
		if (shortcutManager != null) {
			shortcutManager.reportShortcutUsed(channelId);
		}
	}
}
 
源代码10 项目: aptoide-client-v8   文件: DeepLinkIntentReceiver.java
private void dealWithShortcuts() {
  if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {

    ShortcutManager shortcutManager =
        getApplicationContext().getSystemService(ShortcutManager.class);
    Intent fromShortcut = getIntent();

    if (fromShortcut != null) {
      if (fromShortcut.hasExtra("search")) {
        if (fromShortcut.getBooleanExtra("search", false)) {
          shortcutNavigation = true;
          if (shortcutManager != null) {
            shortcutManager.reportShortcutUsed("search");
          }
        }
      } else if (fromShortcut.hasExtra("timeline")) {
        if (fromShortcut.getBooleanExtra("timeline", false)) {
          shortcutNavigation = true;
          if (shortcutManager != null) {
            shortcutManager.reportShortcutUsed("timeline");
          }
        }
      }
    }
  }
  return;
}
 
源代码11 项目: Pix-Art-Messenger   文件: ShortcutService.java
@TargetApi(25)
public void report(Contact contact) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
        ShortcutManager shortcutManager = xmppConnectionService.getSystemService(ShortcutManager.class);
        shortcutManager.reportShortcutUsed(getShortcutId(contact));
    }
}
 
源代码12 项目: 365browser   文件: ChromeTabbedActivity.java
/**
 * Reports that a new tab launcher shortcut was selected or an action equivalent to a shortcut
 * was performed.
 * @param isIncognito Whether the shortcut or action created a new incognito tab.
 */
@TargetApi(Build.VERSION_CODES.N_MR1)
private void reportNewTabShortcutUsed(boolean isIncognito) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) return;

    ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
    shortcutManager.reportShortcutUsed(
            isIncognito ? "new-incognito-tab-shortcut" : "new-tab-shortcut");
}
 
源代码13 项目: Conversations   文件: ShortcutService.java
@TargetApi(25)
public void report(Contact contact) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
        ShortcutManager shortcutManager = xmppConnectionService.getSystemService(ShortcutManager.class);
        shortcutManager.reportShortcutUsed(getShortcutId(contact));
    }
}
 
源代码14 项目: bitmask_android   文件: OpenVPNService.java
@RequiresApi(Build.VERSION_CODES.N_MR1)
private void updateShortCutUsage(VpnProfile profile) {
    if (profile == null)
        return;
    ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
    shortcutManager.reportShortcutUsed(profile.getUUIDString());
}
 
源代码15 项目: launcher-icon   文件: MainActivity.java
private void reportShortcutUsed(String shortcutId) {
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {
        ShortcutManager shortcutManager = (ShortcutManager) getSystemService(SHORTCUT_SERVICE);
        shortcutManager.reportShortcutUsed(shortcutId);
    }
}
 
源代码16 项目: TowerCollector   文件: ApkUtils.java
public static void reportShortcutUsage(Context context, @StringRes int shortcutId) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
        ShortcutManager shortcutManager = (ShortcutManager) context.getSystemService(Context.SHORTCUT_SERVICE);
        shortcutManager.reportShortcutUsed(context.getString(shortcutId));
    }
}
 
源代码17 项目: android-proguards   文件: ShortcutHelper.java
@TargetApi(Build.VERSION_CODES.N_MR1)
public static void reportPostUsed(@NonNull Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) return;
    ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
    shortcutManager.reportShortcutUsed(POST_SHORTCUT_ID);
}
 
源代码18 项目: android-proguards   文件: ShortcutHelper.java
@TargetApi(Build.VERSION_CODES.N_MR1)
public static void reportSearchUsed(@NonNull Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) return;
    ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
    shortcutManager.reportShortcutUsed(SEARCH_SHORTCUT_ID);
}