2019년 3월 25일 월요일

[android] How to get Default Launcher Package Name

Android  How to get Default Launcher Package Name


import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.content.pm.PackageManager;

private String getHomeScreenAppName() {
String homePkgName;
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
ResolveInfo resolveInfo = mContext.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);

homePkgName = resolveInfo.activityInfo.packageName;
//Toast.makeText(this.getApplicationContext(), currentHomePackage, Toast.LENGTH_LONG).show();
Log.d(TAG, "Home Screen Package : " + homePkgName);

return homePkgName;
}

댓글 없음:

댓글 쓰기