Depends on the cause
Without an exam, difficult to tell you the exact cause, but common conditions for those 2 activities include patellar tendonitis
and patellofemoral syndrome.
Quad stretching and quad strengthening, particularly of the vmo (search internet for demo) are a good start. An open patellar knee sleeve or a strap across the patellar tendon can help. Ensure your athletic shoes are up to date and customized.