java - Getting Permissions required by installed apps : Application Force Closes -
i trying make app gives list of installed apps , when item clicked , starts activity states permissions required installed apps. got installed application list, when click app instead of starting new activity , application force closes. following tutorial
mainactivity
package com.example.appslist; import java.util.list; import com.example.appslist.adapter.apkadapter; import com.example.appslist.app.appdata; import android.os.bundle; import android.app.activity; import android.content.intent; import android.content.pm.packageinfo; import android.content.pm.packagemanager; import android.view.view; import android.widget.adapterview; import android.widget.adapterview.onitemclicklistener; import android.widget.listview; public class apklistactivity extends activity implements onitemclicklistener { packagemanager packagemanager; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); packagemanager = getpackagemanager(); list<packageinfo> packagelist = packagemanager .getinstalledpackages(packagemanager.get_permissions); listview mylistview= (listview) findviewbyid(android.r.id.list); mylistview.setadapter(new apkadapter(this, packagelist, packagemanager)); mylistview.setonitemclicklistener(this); } @override public void onitemclick(adapterview<?> parent, view view, int position, long row) { packageinfo packageinfo = (packageinfo) parent .getitematposition(position); appdata appdata = (appdata) getapplicationcontext(); appdata.setpackageinfo(packageinfo); intent appinfo = new intent(getapplicationcontext(), apkinfo.class); startactivity(appinfo); } }
logcat
04-02 11:16:04.536: e/asset(2777): mas: getapppckgandvercode package: com.example.appslist === version 1 04-02 11:16:04.559: d/dalvikvm(2777): trying load lib lib_glossary.so 0x0 04-02 11:16:04.559: i/dalvikvm(2777): unable dlopen(lib_glossary.so): cannot load library: load_library[1083]: library 'lib_glossary.so' not found 04-02 11:16:04.567: e/mbglossarymanager(2777): lib_glossary.so can't loaded 04-02 11:16:04.700: e/asset(2777): mas: getapppckgandvercode package: com.google.android.location === version 8 04-02 11:16:04.708: e/asset(2777): mas: getapppckgandvercode package: com.android.launcher === version 8 04-02 11:16:04.708: e/asset(2777): mas: getapppckgandvercode package: com.android.defcontainer === version 8 04-02 11:16:04.708: e/asset(2777): mas: getapppckgandvercode package: com.navngo.igo.javaclient === version 148360 04-02 11:16:04.715: e/asset(2777): mas: getapppckgandvercode package: com.android.contacts === version 8 04-02 11:16:04.723: e/asset(2777): mas: getapppckgandvercode package: com.arcsoft.photoworkshop === version 5 04-02 11:16:04.778: d/dalvikvm(2777): gc_external_alloc freed 822 objects / 60704 bytes in 56ms 04-02 11:16:04.786: e/asset(2777): mas: getapppckgandvercode package: com.android.phone === version 8 04-02 11:16:04.794: e/asset(2777): mas: getapppckgandvercode package: com.android.calculator2 === version 8 04-02 11:16:04.794: e/asset(2777): mas: getapppckgandvercode package: com.android.htmlviewer === version 8 04-02 11:16:04.801: e/asset(2777): mas: getapppckgandvercode package: com.example.myfirstapp === version 1 04-02 11:16:04.801: e/asset(2777): mas: getapppckgandvercode package: com.android.providers.calendar === version 8 04-02 11:16:04.809: e/asset(2777): mas: getapppckgandvercode package: com.android.bluetooth === version 8 04-02 11:16:04.809: e/asset(2777): mas: getapppckgandvercode package: com.example.sessionmanagement === version 1 04-02 11:16:04.817: e/asset(2777): mas: getapppckgandvercode package: com.android.calendar === version 8 04-02 11:16:04.817: e/asset(2777): mas: getapppckgandvercode package: com.google.android.location === version 8 04-02 11:16:04.817: e/asset(2777): mas: getapppckgandvercode package: com.android.launcher === version 8 04-02 11:16:04.825: e/asset(2777): mas: getapppckgandvercode package: com.android.defcontainer === version 8 04-02 11:16:04.825: e/asset(2777): mas: getapppckgandvercode package: com.navngo.igo.javaclient === version 148360 04-02 11:16:04.872: e/asset(2777): mas: getapppckgandvercode package: com.android.contacts === version 8 04-02 11:16:06.536: d/androidruntime(2777): shutting down vm 04-02 11:16:06.536: w/dalvikvm(2777): threadid=1: thread exiting uncaught exception (group=0x400207e0) 04-02 11:16:06.551: e/androidruntime(2777): fatal exception: main 04-02 11:16:06.551: e/androidruntime(2777): java.lang.classcastexception: android.app.application 04-02 11:16:06.551: e/androidruntime(2777): @ com.example.appslist.apklistactivity.onitemclick(apklistactivity.java:44) 04-02 11:16:06.551: e/androidruntime(2777): @ android.widget.adapterview.performitemclick(adapterview.java:284) 04-02 11:16:06.551: e/androidruntime(2777): @ android.widget.listview.performitemclick(listview.java:3444) 04-02 11:16:06.551: e/androidruntime(2777): @ android.widget.abslistview$performclick.run(abslistview.java:1696) 04-02 11:16:06.551: e/androidruntime(2777): @ android.os.handler.handlecallback(handler.java:587) 04-02 11:16:06.551: e/androidruntime(2777): @ android.os.handler.dispatchmessage(handler.java:92) 04-02 11:16:06.551: e/androidruntime(2777): @ android.os.looper.loop(looper.java:143) 04-02 11:16:06.551: e/androidruntime(2777): @ android.app.activitythread.main(activitythread.java:4717) 04-02 11:16:06.551: e/androidruntime(2777): @ java.lang.reflect.method.invokenative(native method) 04-02 11:16:06.551: e/androidruntime(2777): @ java.lang.reflect.method.invoke(method.java:521) 04-02 11:16:06.551: e/androidruntime(2777): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:858) 04-02 11:16:06.551: e/androidruntime(2777): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616) 04-02 11:16:06.551: e/androidruntime(2777): @ dalvik.system.nativestart.main(native method) 04-02 11:16:08.137: i/process(2777): sending signal. pid: 2777 sig: 9
please help. extremely sorry if question vague . couldn't figure out , trying since long time.
thanks in advance :)
it because using list activity. when using activity listview must have id
set listview id in xml
android:id="@android:id/list
and this
listview yorulistview= (listview) findviewbyid(android.r.id.list);
Comments
Post a Comment