android - My call application stops running, I don't have any code errors -
my application stops running , don't understand why; think code correct. it's simple call application
button b; context= mcontext; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); b = (button) findviewbyid(r.id.call); b.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { if (activitycompat.checkselfpermission(mcontext, manifest.permission.call_phone) != packagemanager.permission_granted) { intent call = new intent(intent.action_dial, uri.parse("tel:0102030405")); startactivity(call); return; } } } ); }
initialize context mcontext = getapplicationcontext(); inside oncreate()
Comments
Post a Comment