android - if something = false display ads -
i have protected boolean follows
protected boolean iskeyinstalled(context context) { // packagename of 'key' app string propackage = "com.funhouse.mytimmieskey"; // package manager final packagemanager pm = context.getpackagemanager(); // list of installed packages list<packageinfo> list = pm.getinstalledpackages(packagemanager.get_disabled_components); // let's iterate through list iterator<packageinfo> = list.iterator(); while(i.hasnext()) { packageinfo p = i.next(); // check if propackage in list , whether package signed // same signature package if((p.packagename.equals(propackage)) && (pm.checksignatures(context.getpackagename(), p.packagename) == packagemanager.signature_match)) return true; } return false; }
i'm trying show ads if false
if(iskeyinstalled(null) != false){ //admob banner linearlayout parent = (linearlayout) findviewbyid(r.id.adveiw); adview ad = new adview(this, adsize.banner, "a14db2c31f42ef0"); parent.addview(ad); adrequest r = new adrequest(); r.settesting(false); ad.loadad(r); }
i have no code errors keeps cashing app.
here logcat
05-11 00:18:37.253: info/activitymanager(52): starting activity: intent { act=android.intent.action.main cat=[android.intent.category.launcher] flg=0x10200000 cmp=com.funhouse.mytimmies/.timsmain bnds=[125,410][235,528] } 05-11 00:18:37.433: info/activitymanager(52): start proc com.funhouse.mytimmies activity com.funhouse.mytimmies/.timsmain: pid=1225 uid=10030 gids={3003} 05-11 00:18:37.814: debug/ddm-heap(1225): got feature list request 05-11 00:18:38.944: debug/androidruntime(1225): shutting down vm 05-11 00:18:38.964: warn/dalvikvm(1225): threadid=3: thread exiting uncaught exception (group=0x4001b188) 05-11 00:18:38.974: error/androidruntime(1225): uncaught handler: thread main exiting due uncaught exception 05-11 00:18:39.044: error/androidruntime(1225): java.lang.runtimeexception: unable start activity componentinfo{com.funhouse.mytimmies/com.funhouse.mytimmies.timsmain}: java.lang.nullpointerexception 05-11 00:18:39.044: error/androidruntime(1225): @ android.app.activitythread.performlaunchactivity(activitythread.java:2496) 05-11 00:18:39.044: error/androidruntime(1225): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2512) 05-11 00:18:39.044: error/androidruntime(1225): @ android.app.activitythread.access$2200(activitythread.java:119) 05-11 00:18:39.044: error/androidruntime(1225): @ android.app.activitythread$h.handlemessage(activitythread.java:1863) 05-11 00:18:39.044: error/androidruntime(1225): @ android.os.handler.dispatchmessage(handler.java:99) 05-11 00:18:39.044: error/androidruntime(1225): @ android.os.looper.loop(looper.java:123) 05-11 00:18:39.044: error/androidruntime(1225): @ android.app.activitythread.main(activitythread.java:4363) 05-11 00:18:39.044: error/androidruntime(1225): @ java.lang.reflect.method.invokenative(native method) 05-11 00:18:39.044: error/androidruntime(1225): @ java.lang.reflect.method.invoke(method.java:521) 05-11 00:18:39.044: error/androidruntime(1225): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:860) 05-11 00:18:39.044: error/androidruntime(1225): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:618) 05-11 00:18:39.044: error/androidruntime(1225): @ dalvik.system.nativestart.main(native method) 05-11 00:18:39.044: error/androidruntime(1225): caused by: java.lang.nullpointerexception 05-11 00:18:39.044: error/androidruntime(1225): @ com.funhouse.mytimmies.timsmain.iskeyinstalled(timsmain.java:76) 05-11 00:18:39.044: error/androidruntime(1225): @ com.funhouse.mytimmies.timsmain.oncreate(timsmain.java:27) 05-11 00:18:39.044: error/androidruntime(1225): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1047) 05-11 00:18:39.044: error/androidruntime(1225): @ android.app.activitythread.performlaunchactivity(activitythread.java:2459) 05-11 00:18:39.044: error/androidruntime(1225): ... 11 more 05-11 00:18:39.095: info/process(52): sending signal. pid: 1225 sig: 3
i'm guessing final packagemanager pm = context.getpackagemanager();
is line 76 error occuring, context passing null...it's unable start activity since error occuring in oncreate method...pass in this
(being activity) context , it'll fix problem.
Comments
Post a Comment