Note that there are some explanatory texts on larger screens.

plurals
  1. POGet uid of application from a list of application
    primarykey
    data
    text
    <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ListView internetapps= (ListView) findViewById(R.id.list); ArrayList myList = new ArrayList(); PackageManager pm = this.getPackageManager(); List&lt;PackageInfo&gt; applist= pm.getInstalledPackages(0); Iterator&lt;PackageInfo&gt; it= applist.iterator(); while (it.hasNext()){ PackageInfo pk= (PackageInfo)it.next(); if(PackageManager.PERMISSION_GRANTED==(pm.checkPermission(Manifest.permission.INTERNET, pk.packageName))) //checking if the package is having INTERNET permission { myList.add(""+pk.applicationInfo.loadLabel(pm)); } } internetapps.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, myList)); final TextView text1 = (TextView) findViewById(R.id.text2); internetapps.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View arg1, int list_position,long app_Uid) { String app_selected=parent.getItemAtPosition(list_position).toString(); final PackageManager pm = getPackageManager(); //get a list of installed apps. List&lt;ApplicationInfo&gt; packages = pm.getInstalledApplications(PackageManager.GET_META_DATA); long UID; //loop through the list of installed packages and see if the selected //app is in the list for (ApplicationInfo packageInfo : packages) { if(packageInfo.packageName.equals(app_selected)){ //get the UID for the selected app UID = packageInfo.uid; text1.setText("Yeah"); } else { text1.setText("No"); } } } }); } </code></pre> <p>How to get uid of application from application in a list. I try to get the uid by using the above code, but it always show negative result ( I use setText to trace which the code it run in if..else...it always show "No" after i click on an item ). Anything wrong with my code.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload