I have created custom soft keyboard with images and my task is want to send selected image to the currently selected Application by the user like google hangout but i can get Installed application package name and icon using Package Manager like that if am using google hangout application means i have to get google hangout application package name and from my custom keyboard i have to share selected images directly to the hangout chat conversation as a message how can i solve this issue.
You can get all the installed package details.
public ArrayList<PackageInfoStruct> getInstalledApps(Activity mActivity) {
ArrayList<PackageInfoStruct> res = new ArrayList<PackageInfoStruct>();
List<PackageInfo> packs = mActivity.getPackageManager()
.getInstalledPackages(0);
for (int i = 0; i < packs.size(); i++) {
PackageInfo p = packs.get(i);
PackageInfoStruct newInfo = new PackageInfoStruct();
newInfo.appname = p.applicationInfo.loadLabel(
mActivity.getPackageManager()).toString();
newInfo.pname = p.packageName;
newInfo.datadir = p.applicationInfo.dataDir;
newInfo.versionName = p.versionName;
newInfo.versionCode = p.versionCode;
newInfo.icon = p.applicationInfo.loadIcon(mActivity
.getPackageManager());
res.add(newInfo);
}
return res;
}
public class PackageInfoStruct {
String appname = "";
String pname = "";
String versionName = "";
int versionCode = 0;
Drawable icon;
String datadir = "";
}
Call getInstalledApps
ArrayList<PackageInfoStruct> installedPackageDetails = getInstalledApps(getActivity());
You can use above method to display list of installed app and on selected you can details from as per selected item. PackageInfoStruct
class contains details for package