android - onActivityResult Never gets called Phonegap Cordova -


i using barcode scanner plugin phonegap using zxing library project.

i have code works on galaxy tab 2 (7"). same code doesn't work on galaxy s3.

problem : when zxing captureactivity scans barcode finish captureactivity , calling activity never comes onactivityresult method.

mainfest.

<activity         android:name=".activity.mainactivity"         android:configchanges="orientation|keyboardhidden|keyboard|screensize|locale"         android:label="@string/app_name"         android:theme="@android:style/theme.black.notitlebar" >         <intent-filter>             <action android:name="android.intent.action.main" />              <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity>     <activity         android:name="com.google.zxing.client.android.captureactivity"         android:configchanges="orientation|keyboardhidden"         android:screenorientation="landscape"         android:theme="@android:style/theme.notitlebar.fullscreen"         android:windowsoftinputmode="statealwayshidden" >         <intent-filter>             <action android:name="com.phonegap.plugins.barcodescanner.scan" />              <category android:name="android.intent.category.default" />         </intent-filter>     </activity> </application> 

mainactivity.java

public void startactivityforresult(cordovaplugin command, intent intent,         int requestcode) {     this.activityresultcallback = command;     this.activityresultkeeprunning = this.keeprunning;      // if multitasking turned on, disable activities return     // results     if (command != null) {         this.keeprunning = false;     }      // start activity     startactivityforresult(intent, requestcode); }  protected void onactivityresult(int requestcode, int resultcode,         intent intent) {     cordovaplugin callback = this.activityresultcallback;           if (callback != null) {               callback.onactivityresult(requestcode, resultcode, intent);           } else {               log.e(tag, "plugin callback null");           }       // else continue other code need in method      super.onactivityresult(requestcode, resultcode, intent);   } 

barcodescanner plugin

private static final string scan_intent = "com.phonegap.plugins.barcodescanner.scan"; public void scan() {      intent intentscan = new intent(scan_intent);     intentscan.addcategory(intent.category_default);     this.cordova.startactivityforresult((cordovaplugin) this, intentscan,             appconstants.camera_scan_request_code);  } 

i have zxing projet library project.

help appreciated.

per cordova web view documentation

you need have code in activity:

@override public void setactivityresultcallback(cordovaplugin plugin) {     this.activityresultcallback = plugin;         }  public void startactivityforresult(cordovaplugin command, intent intent, int requestcode) {     this.activityresultcallback = command;     this.activityresultkeeprunning = this.keeprunning;      // if multitasking turned on, disable activities return results     if (command != null) {         this.keeprunning = false;     }      // start activity     super.startactivityforresult(intent, requestcode); }  @override protected void onactivityresult(int requestcode, int resultcode, intent intent) {     super.onactivityresult(requestcode, resultcode, intent);     cordovaplugin callback = this.activityresultcallback;     if (callback != null) {         callback.onactivityresult(requestcode, resultcode, intent);     } } 

and in addition to:

this.cordova.startactivityforresult((cordovaplugin) this, intentscan, appconstants.camera_scan_request_code); 

you need have following method in plugin:

@override public void onactivityresult(int requestcode, int resultcode, intent intent) {     //do result     super.onactivityresult(requestcode, resultcode, intent); } 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -