AndroidアプリのIntentクラス名を取得する
Androidで明示的なintentを扱おうと思ったのだけれど、実際にAndroidにインストールしているアプリのクラス名がわからないので、それを取得するアプリを作ってみました。取得の仕方は日本Andoridの会のメーリングリストで教えていただきました。
(とにかくインストールされているアプリのパッケージ名を全て取得する方法をこちらに書きました)
取得方法
//クラス名取得 Intent it = new Intent(Intent.ACTION_MAIN, null); it.addCategory(Intent.CATEGORY_LAUNCHER); PackageManager pManager = getPackageManager(); List<ResolveInfo> appList = pManager.queryIntentActivities(it,0); Collections.sort(appList,new ResolveInfo.DisplayNameComparator(pManager)); //Dataにして String textdata = ""; for (ResolveInfo info : appList) { textdata = textdata + info.activityInfo.name +"\n"; } //暗黙のintentでデータを投げる Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, textdata); intent.setType( "text/plain" ); startActivity(intent);
取得したクラス名情報を、暗黙のインテントで丸投げすると言うプログラムです。Androidマーケットに公開しました。需要は無いと思いますが、とりあえず紹介しておきます。