perumal316 wrote:
> Hi All,
> 
> I have the code to get the list of packages installed in phone. I have
> represented the list in the form of Array List, below is the code
> snippet. But upon clicking in  the package name I want to start that
> application, but how do I get the respective class name and package
> name to run?
> 
> Is there any other method which I can try to start an application?
> 
> 
> 
>            ArrayList<String> PackageNames = null;
>                 List<PackageInfo> lis =
> pm.getInstalledPackages(GET_MINIMAL);
>               Pkgs = (ListView) findViewById(R.id.package_list);
> 
> 
>               for (PackageInfo pi : lis)
>                       packages.put(pi.packageName, pi);
> 
>               PackageNames = new ArrayList<String>(packages.keySet());
>               Collections.sort(PackageNames);
>               PackageNames.add(0, "All");
>               Pkgs.setAdapter(new ArrayAdapter<String>(this,
>                               android.R.layout.simple_list_item_1, 
> PackageNames));
> 
>               Pkgs.setOnItemClickListener(new OnItemClickListener() {
> 
>                       public void onItemClick(AdapterView<?> arg0, View v, 
> int pos,
>                                       long rowId) {
>                               Intent i = new Intent();
>                               i.setComponent(new ComponentName(class 
> name,packagename));
>                               startActivity(i);
> 
>                       }
>               });
> 
> I have tried intent to start the activity, but don't know the class
> name and package name to pass in the ComponentName() to start
> activity.

Take a look at Launchalot, one of the samples from one of my books, and
see if it helps:

http://github.com/commonsguy/cw-advandroid/tree/master/Introspection/Launchalot/

Here, I too use PackageManager to query for available packages, display
them in a list, and launch an activity for each package on a click of
that package's item in the list.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training in NYC: 10-11 April 2010: http://guruloft.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to