Tuesday, 15 July 2014

java - OnActivityResult () -



java - OnActivityResult () -

i have code should allow me take value calculator , utilize further:

//-----------------this section creates keypad functionality (int o = 0; o < keybuttons.length; o++) { final int n = o; keybuttons[o] = (button) findviewbyid(data.keyids[n]); keybuttons[o].setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { seek { string tmp = texts[selectedit].gettext() .tostring(); switch (n) { case 3: texts[selectedit].settext(tmp.substring(0, tmp.length() - 1)); break; //get cursor position , delete char case 7: { // create intent realcalc. intent intent2 = new intent("uk.co.quarticsoftware.realcalc"); double x = 0; // set initial value (double). if (!texts[selectedit].gettext() .tostring() .equals("")) { x = double.valueof(texts[selectedit].gettext() .tostring()); } intent2.putextra("x", x); // launch calculator seek { startactivityforresult(intent2, 0); } grab (activitynotfoundexception e) { intent intent = new intent(intent.action_view, uri.parse("market://details?id=uk.co.nickfines.realcalc")); seek { startactivity(intent); } grab (activitynotfoundexception f) { // google play store app not available. } } break; } //open calculator case 11: { if (!tmp.contains("e")) texts[selectedit].settext(tmp + "" + keybuttons[n].gettext()); break; } //check e if dont have default case case 15: { tl.setvisibility(view.gone); break; } //simulate button default: { texts[selectedit].settext(tmp + "" + keybuttons[n].gettext()); //get cursor start , end , entire string // replace selected string button text //insert break; } } //end of switch } //end of seek grab (activitynotfoundexception e) { intent intent = new intent(intent.action_view, uri.parse("market://details?id=uk.co.nickfines.realcalc")); // calculator not installed } //calculator.num=n; grab (exception e) { stringwriter sw = new stringwriter(); e.printstacktrace(new printwriter(sw)); easyphysactivity.error = sw.tostring(); } } @override protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); if (resultcode == activity.result_ok) { // user pressed ok. double value = data.getdoubleextra("x", double.nan); if (double.isnan(value)) { // calculation result "error". } else { // calculation result ok. } } else { // user pressed cancel or button. } } }); } //----------------------------------------

but doesn't these 3 lines:

@override protected void onactivityresult (int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data);

if delete @override becomes better, still shows error

super.onactivityresult(requestcode, resultcode, data);

what going wrong in here?

you cannot override onactivityresult within onclicklistener because not exist in base of operations class. move onactivityresult code within activity class, not onclicklistner.

java android methods

No comments:

Post a Comment