android - Alarm is not working at entering location -


i want trigger alarm when user enters specific location. trying switch cell normal mode silent mode, when user enters location. when added code in app, did not work. please tell me , wrong?

logcat error

10-10 11:40:39.711: e/androidruntime(26894): fatal exception: main 10-10 11:40:39.711: e/androidruntime(26894): java.lang.runtimeexception: unable start activity componentinfo{com.haider.trymap/com.haider.trymap.proximityactivity}: java.lang.nullpointerexception 10-10 11:40:39.711: e/androidruntime(26894):    @ android.app.activitythread.performlaunchactivity(activitythread.java:2255) 10-10 11:40:39.711: e/androidruntime(26894):    @ android.app.activitythread.handlelaunchactivity(activitythread.java:2309) 10-10 11:40:39.711: e/androidruntime(26894):    @ android.app.activitythread.access$700(activitythread.java:157) 10-10 11:40:39.711: e/androidruntime(26894):    @ android.app.activitythread$h.handlemessage(activitythread.java:1289) 10-10 11:40:39.711: e/androidruntime(26894):    @ android.os.handler.dispatchmessage(handler.java:99) 10-10 11:40:39.711: e/androidruntime(26894):    @ android.os.looper.loop(looper.java:176) 10-10 11:40:39.711: e/androidruntime(26894):    @ android.app.activitythread.main(activitythread.java:5317) 10-10 11:40:39.711: e/androidruntime(26894):    @ java.lang.reflect.method.invokenative(native method) 10-10 11:40:39.711: e/androidruntime(26894):    @ java.lang.reflect.method.invoke(method.java:511) 10-10 11:40:39.711: e/androidruntime(26894):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1102) 10-10 11:40:39.711: e/androidruntime(26894):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:869) 10-10 11:40:39.711: e/androidruntime(26894):    @ dalvik.system.nativestart.main(native method) 10-10 11:40:39.711: e/androidruntime(26894): caused by: java.lang.nullpointerexception 10-10 11:40:39.711: e/androidruntime(26894):    @ com.haider.trymap.proximityactivity.oncreate(proximityactivity.java:49) 10-10 11:40:39.711: e/androidruntime(26894):    @ android.app.activity.performcreate(activity.java:5326) 10-10 11:40:39.711: e/androidruntime(26894):    @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1097) 10-10 11:40:39.711: e/androidruntime(26894):    @ android.app.activitythread.performlaunchactivity(activitythread.java:2218) 10-10 11:40:39.711: e/androidruntime(26894):    ... 11 more 

proximityactivity.java

(the piece of code gives error)

@override     protected void oncreate(bundle savedinstancestate) {         // todo auto-generated method stub         super.oncreate(savedinstancestate);  boolean proximity_entering = getintent().getbooleanextra(locationmanager.key_proximity_entering, true); double lat = getintent().getdoubleextra("lat", 0);  double lng = getintent().getdoubleextra("lng", 0);  string strlocation = double.tostring(lat)+","+double.tostring(lng);           if(proximity_entering){             toast.maketext(getbasecontext(),"entering region"  ,toast.length_long).show();             notificationtitle="proximity - entry";             notificationcontent="entered region:" + strlocation;             tickermessage = "entered region:" + strlocation;              intent normal = new intent(getbasecontext(), normal_mode.class);             pendingintent nor = pendingintent.getbroadcast(getbasecontext(), rqs_1, normal, 0);             alarmmanager noralarm = (alarmmanager) getsystemservice(context.alarm_service);             noralarm.set(alarmmanager.rtc_wakeup, targetcal.gettimeinmillis(), nor);           }else{             toast.maketext(getbasecontext(),"exiting region"  ,toast.length_long).show();             notificationtitle="proximity - exit";             notificationcontent="exited region:" + strlocation;             tickermessage = "exited region:" + strlocation;          }          intent notificationintent = new intent(getapplicationcontext(),notificationview.class);         notificationintent.putextra("content", notificationcontent );          /** needed make intent different previous intents */         notificationintent.setdata(uri.parse("tel:/"+ (int)system.currenttimemillis()));          /** creating different tasks each notification. see flag intent.flag_activity_new_task */         pendingintent pendingintent = pendingintent.getactivity(getapplicationcontext(), 0, notificationintent, intent.flag_activity_new_task);          /** getting system service notificationmanager */         notificationmanager nmanager = (notificationmanager) getapplicationcontext().getsystemservice(context.notification_service);          /** configuring notification builder create notification */         notificationcompat.builder notificationbuilder = new notificationcompat.builder(getapplicationcontext())                             .setwhen(system.currenttimemillis())                             .setcontenttext(notificationcontent)                             .setcontenttitle(notificationtitle)                             .setsmallicon(r.drawable.ic_launcher)                             .setautocancel(true)                             .setticker(tickermessage)                             .setcontentintent(pendingintent)                             .setsound(ringtonemanager.getdefaulturi(ringtonemanager.type_notification));                                       /** creating notification notification builder */         notification notification = notificationbuilder.build();          /** sending notification system.           * first argument ensures each notification having unique id           * if 2 notifications share same notification id, last notification replaces first notification           * */         nmanager.notify((int)system.currenttimemillis(), notification);          /** finishes execution of activity */         finish();       }     } 


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -