I am developing a small application which displays the installed application as a list in a spinner. Only the application name is displayed as spinner values. Whenever I select an application from spinner I need to retrieve the UID of the selected application. How can I implement the function?
The following is my code for getting the application name from the spinner
appspinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View arg1,
int app_pos, long app_id) {
// TODO Auto-generated method stub
String app_selected=parent.getItemAtPosition(app_pos).toString();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
return;
}
});
The installed application is stored in a list using the PackageManager class and using PackageInfo class I am getting the name of the application.