If you haven't used one of your credit cards for months or even years, don't be surprised when you receive a letter in the mail notifying you of an account cancellation. Some credit issuers may be kind enough to provide advance notice; however, in many cases you won't learn of the cancellation until after the fact. And yes, they can do that for now - it's legal.
An account cancellation will immediately lower your total available credit, increase your credit utilization ratio, and hurt your credit score. In addition, the available credit you lost may be difficult to replace given the current state of the credit markets, so it's best to avoid any possible cancellations due to inactivity.
Try setting up a small recurring payment on your credit card, such as a gym membership or internet bill, and activate auto payments to ensure it will be paid in full each month. If that's not a viable option, try using the card to make a small purchase at least once every 2-3 months. It doesn't have to be much, but rather something simple like lunch out or food at the grocery store.