开发者

Launching unknown activities from an android application

I want to make an android application that shows a li开发者_StackOverflow社区sting of applications (downloaded from the android market) and launches the one that the user selects. From what I've read, I'd have to use intents like this:

  Intent intent = new Intent();
  intent.setClassName(packageName, className);
  startActivity(intent);

I just want to be able to launch the applications, not a specific activity that they could have.

My question is: how could I launch these applications if I don't know their packageName or className? or maybe, how could I get to know their className and packageName, if it's a closed source application that I didn't develop.

Thanks.


Use PackageManager to find out the installed applications and such. In fact, you will find this book sample project does a fair bit of what you need.


In short, you can't. But, Android will let you get a hold of a list of installed packages along with their fully qualified class names. Check out the code at this link for an example of how to get this package listing. As far as I know, there's no way to determine from where the package was installed, but what you could do is compare it against a list of known applications to be preinstalled on the device and filter those out. The idea being that if it's not a preinstalled application, it was likely installed through the marketplace.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜