问题
Alternatvely, is there an easy way to know the package name of a system app ?
回答1:
I just was Developing an App locker that have a category for important app to offer user to lock them. and obviously default SMS app is important app to lock. so i create my own list of default sms apps package name. I hope this will be helpful for you and others help me to improve this list:
"com.google.android.apps.messaging"
"com.jb.gosms"
"com.concentriclivers.mms.com.android.mms"
"fr.slvn.mms"
"com.android.mms"
"com.sonyericsson.conversations"
回答2:
What are you exactly trying to do? Alternatively, why do you need such a list ?
As a general advice, you shouldn't code anything according to a static list, because anything related to this list is likely to evolve.
回答3:
ya you can get
public class ListofAppinMyDevice {
public class PInfo {
public String appname = "";
public String pname = "";
public String versionName = "";
public int versionCode = 0;
}
public ArrayList<PInfo> getInstalledApps(boolean getSysPackages)
{
ArrayList<PInfo> res = new ArrayList<PInfo>();
List<PackageInfo> packs = AppUtils.mContext.getPackageManager().getInstalledPackages(0);
for(int i=0;i<packs.size();i++) {
PackageInfo p = packs.get(i);
ApplicationInfo s=p.applicationInfo;
if(((s.flags & ApplicationInfo.FLAG_SYSTEM)!=1))
{
PInfo newInfo = new PInfo();
newInfo.appname = p.applicationInfo.loadLabel(AppUtils.mContext.getPackageManager()).toString();
newInfo.pname = p.packageName;
newInfo.versionName = p.versionName;
newInfo.versionCode = p.versionCode;
System.out.println("3rd party apps-------------------"+p.packageName +"--------"+newInfo.appname);
res.add(newInfo);
}
if ((!getSysPackages) ) {
continue ;
}
}
return res;
}
}
//you can get the system installed app by using this below method
public static void listPackages() {
ListofAppinMyDevice getmyApp=new ListofAppinMyDevice();
apps =getmyApp.getInstalledApps(true);
/* false = will get 3rd part package detials
true -will get all system packages */
System.out.println("Total InstalledApps in your device--=="+apps.size());
final int max = apps.size();
applist=new StringBuilder();
for (int i=0; i<max; i++) {
String packageName=apps.get(i).pname;
}
来源:https://stackoverflow.com/questions/8388028/is-there-a-list-of-all-stock-messaging-apps-package-names-for-all-android-phone