ホーム ランチャーのパッケージ名を取得する方法について問題が発生しました。
Android には、次の 2 種類のホーム ランチャーがあります。
- オリジナルランチャー
- go-launcher や OEM などの 3/3 ランチャー
そのため、指定したパッケージ名を使用して開始することはできません。
最後に、解決策を見つけます。
これを行うための他の良い方法はありますか?
//find out the package with ACTION_MAIN & CATEGORY_HOME
Intent i = new Intent();
i.setAction(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_HOME);
PackageManager pm = this.getPackageManager();
List<ResolveInfo> ris = (List<ResolveInfo>) pm.queryIntentActivities(i,
PackageManager.MATCH_DEFAULT_ONLY);
Log.i("", ris.size() + "");
//seletc the first one , doc says the first one is the home launcher currently
if (ris != null && ris.size() > 0) {
String pkg = ris.get(0).activityInfo.packageName;
Log.i("HOME PKG NAME ", pkg);
//start it
i.setClassName(ris.get(0).activityInfo.packageName, ris.get(0).activityInfo.name);
startActivity(i);
}
https://groups.google.com/forum/?fromgroups=#!topic/android-developers/-5aGSOdwJ-8ありがとうございます