android - Make EditText work on an activity start -



android - Make EditText work on an activity start -

i'm trying in app billing remove ads.

i have bit of code :

iabhelper.queryinventoryfinishedlistener mgotinventorylistener = new iabhelper.queryinventoryfinishedlistener() { public void onqueryinventoryfinished(iabresult result, inventory inventory) { // have been disposed of in meantime? if so, quit. if (mabhelper == null) return; // failure? if (result.isfailure()) { return; } // have premium upgrade? purchase premiumpurchase = inventory.getpurchase(sku_premium); mispremium = premiumpurchase != null; updateinterface(); } }; /** * updates interface */ private void updateinterface() { button savebutton = (button) findviewbyid(r.id.btupgrade); button btupgrade = (button) findviewbyid(r.id.btupgrade); if (mispremium) { final edittext edittext = (edittext) findviewbyid(r.id.edittextantiadskey); savebutton = (button) findviewbyid(r.id.buttonsaveantiadskey); if (edittext != null && edittext.gettext() != null) { constants.anti_ads_value = edittext.gettext().tostring().trim(); } else { constants.anti_ads_value = "error"; } if ("".equals(constants.anti_ads_value) || constants.anti_ads_value.equals(this .getstring(r.string.app_name))) { constants.anti_ads_value = ""; toast.maketext(mainactivity.this, getresources().getstring(r.string.app_name), toast.length_short).show(); } else { toast.maketext( mainactivity.this, getresources().getstring(r.string.app_name) + " (" + edittext.gettext() + ")", toast.length_long) .show(); } sharedpreferences settings = getsharedpreferences( constants.preferences_file, context.mode_private); sharedpreferences.editor editor = settings.edit(); editor.putstring(constants.anti_ads_key, constants.anti_ads_value); editor.commit(); editor.clear(); } else { btupgrade.setenabled(true); } }

the thing have press button create code works. code works on activity start.

i'm newbie, i'm wondering if possible ?

thanks

put code straight after initialize editbox. if want maintain on button click , still want execute on start can write `

savebutton.performclick()

after savebutton onclicklistener code block. set within activity's onresume() method block if activity starts pause executed.

android button android-edittext

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -