android - getPacketManager().resolveActivity(...) - Fails only with system applications -


i retrieve installed applications via following code:

final intent mainintent = new intent(intent.action_main, null); mainintent.addcategory(intent.category_launcher); final list < resolveinfo > pkgappslist = context.getpackagemanager().queryintentactivities(mainintent, 0); 

when call resolveactivity() function system packagenames receive following exception:

java.lang.nullpointerexception: attempt invoke virtual method 'java.lang.string android.net.uri.gethost()' on null object reference         @ android.os.parcel.readexception(parcel.java:1546)         @ android.os.parcel.readexception(parcel.java:1493)         @ android.content.pm.ipackagemanager$stub$proxy.resolveintent(ipackagemanager.java:2513)         @ android.app.applicationpackagemanager.resolveactivityasuser(applicationpackagemanager.java:545)         @ android.app.applicationpackagemanager.resolveactivity(applicationpackagemanager.java:539)         @ com.github.aayvazyan.polyse.util.apkinfo.getresolveinfo(apkinfo.java:87) 

this exception reproduceable via:

    intent intent = new intent();     intent.setpackage("com.google.android.calendar");     intent.addcategory(intent.category_launcher);     resolveinfo result = getpackagemanager().resolveactivity(intent, 0); 

i use sdk 21 , build tools "21.1.1"

to fix problem initialized intent following instead of empty constructor:

    intent intent = new intent(intent.action_main, null); 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -