Question

I want to get all the Applications that have intentlisteners to

Intent.CATEGORY_HOME

so basically the launcher

I have this code :

final Intent mainIntent = null;
    mainIntent.addCategory(Intent.CATEGORY_HOME);

    final List pkgAppsList = this.getPackageManager().queryIntentActivities( mainIntent, 0); 

    ListView app_list = (ListView) findViewById(R.id.application_list);


    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_1, android.R.id.text1,pkgAppsList);
    app_list.setAdapter(adapter);

this should return the applications that listen to the homekey press

but I only get a Nullpointer exception

Was it helpful?

Solution

use

Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); 

instead of

Intent mainIntent = null;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top