Starting an installed app from my app

121 Views Asked by At
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
            //String s1 = ?
    Intent i = new Intent();
    PackageManager manager = getPackageManager();
    i = manager.getLaunchIntentForPackage(packageName);
    i.addCategory(Intent.CATEGORY_LAUNCHER);
    startActivity(i);

}

EDIT:I saw that if we write the app package name in place of packageName in quotes then it opens that app. I mean

i = manager.getLaunchIntentForPackage("com.android.mms");

instead of

i = manager.getLaunchIntentForPackage(packageName);

So I wan define a string s that will get the package name of the app that is selected based on the position. How can I do that?

This isnt a duplicate cuz I have tried all that. I just wanna know how to edit the above code and get what I want.

0

There are 0 best solutions below