What is the application error:6 in Android licensing -


here code:

some time application error :3 or :6 , time application not licensed dialog.

public class mainactivity extends activity {     private static final string base64_public_key = "my public key";      // generate own 20 random bytes, , put them here.     private static final byte[] salt = new byte[] {         -43, 12, 76, -124, -101, -57, 74, -64, 51, 88, -95, -45, 77, -117, -36, -113, -11, 32, -64,         89     };      private textview mstatustext;     private button mchecklicensebutton;      private licensecheckercallback mlicensecheckercallback;     private licensechecker mchecker;     // handler on ui thread.     private handler mhandler;      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         requestwindowfeature(window.feature_indeterminate_progress);         setcontentview(r.layout.main);          mstatustext = (textview) findviewbyid(r.id.status_text);         mchecklicensebutton = (button) findviewbyid(r.id.check_license_button);         mchecklicensebutton.setonclicklistener(new view.onclicklistener() {             public void onclick(view view) {                 docheck();             }         });          mhandler = new handler();          // try use more data here. android_id single point of attack.         string deviceid = secure.getstring(getcontentresolver(), secure.android_id);          // library calls when it's done.         mlicensecheckercallback = new mylicensecheckercallback();         // construct licensechecker policy.         mchecker = new licensechecker(             this, new servermanagedpolicy(this,                 new aesobfuscator(salt, getpackagename(), deviceid)),             base64_public_key);         docheck();     }      protected dialog oncreatedialog(int id) {         final boolean bretry = id == 1;         return new alertdialog.builder(this)             .settitle(r.string.unlicensed_dialog_title)             .setmessage(bretry ? r.string.unlicensed_dialog_retry_body : r.string.unlicensed_dialog_body)             .setpositivebutton(bretry ? r.string.retry_button : r.string.buy_button, new dialoginterface.onclicklistener() {                 boolean mretry = bretry;                 public void onclick(dialoginterface dialog, int which) {                     if ( mretry ) {                         docheck();                     } else {                         intent marketintent = new intent(intent.action_view, uri.parse(                                 "http://play.google.com/store/apps/details?id=com.android.sendemail"));                             startactivity(marketintent);                                             }                 }             })             .setnegativebutton(r.string.quit_button, new dialoginterface.onclicklistener() {                 public void onclick(dialoginterface dialog, int which) {                     finish();                 }             }).create();     }      private void docheck() {         mchecklicensebutton.setenabled(false);         setprogressbarindeterminatevisibility(true);         mstatustext.settext(r.string.checking_license);         mchecker.checkaccess(mlicensecheckercallback);     }      private void displayresult(final string result) {         mhandler.post(new runnable() {             public void run() {                 mstatustext.settext(result);                 setprogressbarindeterminatevisibility(false);                 mchecklicensebutton.setenabled(true);             }         });     }      private void displaydialog(final boolean showretry) {         mhandler.post(new runnable() {             public void run() {                 setprogressbarindeterminatevisibility(false);                 showdialog(showretry ? 1 : 0);                 mchecklicensebutton.setenabled(true);             }         });     }          private class mylicensecheckercallback implements licensecheckercallback {         public void allow(int policyreason) {             if (isfinishing()) {                 // don't update ui if activity finishing.                 return;             }             // should allow user access.             displayresult(getstring(r.string.allow));         }          public void dontallow(int policyreason) {             if (isfinishing()) {                 // don't update ui if activity finishing.                 return;             }             displayresult(getstring(r.string.dont_allow));             // should not allow access. in cases, app should assume             // user has access unless encounters this. if does,             // app should inform user of unlicensed ways             // , either shut down app or limit user             // restricted set of features.             // in example, show dialog takes user market.             // if reason lack of license service             // unavailable or there problem, display             // retry button on dialog , different message.             displaydialog(policyreason == policy.retry);         }          public void applicationerror(int errorcode) {             if (isfinishing()) {                 // don't update ui if activity finishing.                 return;             }             // polite way of saying developer made mistake             // while setting or calling license checker library.             // please examine error code , fix error.             string result = string.format(getstring(r.string.application_error), errorcode);             displayresult(result);         }     }      @override     protected void ondestroy() {         super.ondestroy();         mchecker.ondestroy();     } 

error code 6 means missing permission check licensing application manifest.

<uses-permission android:name="com.android.vending.check_license" /> 

error code 3 means app isn't on google marketplace license server can't determine if supposed have license or not yet.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -

java - Copying object fields -