在第三方SDK意图上调用startActivityForResult时出错

时间:2016-07-04 18:32:01

标签: javascript android android-intent android-gradle nativescript

我正在创建一个NativeScript应用。我有一个.jar文件,我通过Gradle拉入我的应用程序。我可以很好地与.jar的类/对象进行交互。但是,当我尝试使用startActivityForResult的intent时,我收到一个错误:

Error: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.xyz.payment.REQUEST (has extras) }

我的代码:

let paymentRequest = new com.xyz.payment.PaymentRequest(new java.math.BigDecimal("50.00"));

app.android.onActivityResult = function (requestCode, resultCode, data) {
    console.log('onActivityResult');
};

let act = app.android.foregroundActivity || app.android.startActivity;

act.startActivityForResult(paymentRequest.createIntent(), 0);

// also tried
// app.android.currentContext.startActivityForResult(paymentRequest.createIntent(), 0);

我还将此添加到我的清单文件中:

<activity android:name="com.xyz.payment.REQUEST"/>

编辑。添加了堆栈跟踪:

JS: ORIGINAL EXCEPTION: Error: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.xyz.payment.REQUEST (has extras) }
JS:     android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1809)
JS:     android.app.Instrumentation.execStartActivity(Instrumentation.java:1523)
JS:     android.app.Activity.startActivityForResult(Activity.java:4223)
JS:     android.app.Activity.startActivityForResult(Activity.java:4182)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:726)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:712)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:693)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:683)
JS:     com.tns.gen.android.widget.AdapterView_OnItemClickListener.onItemClick(AdapterView_OnItemClickListener.java:14)
JS:     android.widget.AdapterView.performItemClick(AdapterView.java:310)
JS:     android.widget.AbsListView.performItemClick(AbsListView.java:1155)
JS:     android.widget.AbsListView$PerformClick.run(AbsListView.java:3096)
JS:     android.widget.AbsListView$3.run(AbsListView.java:4011)
JS:     android.os.Handler.handleCallback(Handler.java:751)
JS:     android.os.Handler.dispatchMessage(Handler.java:95)
JS:     android.os.Looper.loop(Looper.java:154)
JS:     android.app.ActivityThread.main(ActivityThread.java:6044)
JS:     java.lang.reflect.Method.invoke(Native Method)
JS:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
JS:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
JS: ORIGINAL STACKTRACE:
JS: Error: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.aevi.payment.REQUEST (has extras) }
JS:     android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1809)
JS:     android.app.Instrumentation.execStartActivity(Instrumentation.java:1523)
JS:     android.app.Activity.startActivityForResult(Activity.java:4223)
JS:     android.app.Activity.startActivityForResult(Activity.java:4182)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:726)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:712)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:693)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:683)
JS:     com.tns.gen.android.widget.AdapterView_OnItemClickListener.onItemClick(AdapterView_OnItemClickListener.java:14)
JS:     android.widget.AdapterView.performItemClick(AdapterView.java:310)
JS:     android.widget.AbsListView.performItemClick(AbsListView.java:1155)
JS:     android.widget.AbsListView$PerformClick.run(AbsListView.java:3096)
JS:     android.widget.AbsListView$3.run(AbsListView.java:4011)
JS:     android.os.Handler.handleCallback(Handler.java:751)
JS:     android.os.Handler.dispatchMessage(Handler.java:95)
JS:     android.os.Looper.loop(Looper.java:154)
JS:     android.app.ActivityThread.main(ActivityThread.java:6044)
JS:     java.lang.reflect.Method.invoke(Native Method)
JS:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
JS:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
JS:     at Error (native)
JS:     at AppComponent.onTap (/data/data/org.nativescript.androidtest/files/app/app.component.js:18:13)
JS:     at DebugAppView._View_AppComponent0._handle_itemTap_1_0 (AppComponent.template.js:83:28)
JS:     at Object.<anonymous> (/data/data/org.nativescript.androidtest/files/app/tns_modules/@angular/core/src/linker/view.js:366:24)
JS:     at ZoneDelegate.invoke (/data/data/org.nativescript.androidtest/files/app/tns_modules/zone.js/dist/zone-node.js:281:29)
JS:     at Object.NgZoneImpl.inner.inner.fork.onInvoke (/data/data/org.nativescript.androidtest/files/app/tns_modules/@angular/core/src/zone/ng_zone_impl.js:46:41)
JS:     at ZoneDelegate.invoke (/data/data/org.nativescript.androidtest/files/app/tns_modules/zone.js/dist/zone-node.js:280:35)
JS:     at Zone.runGuarded (/data/data/org.nativescript.androidtest/files/app/tns_modules/zone.js/dist/zone-node.js:188:48)
JS:     at Object.callback (/data/data/org.nativescript.androidtest/files/app/tns_modules/zone.js/dist/zone-node.js:164:30)
JS:     at ListView.Observable.notify (/data/data/org.nativescript.androidtest/files/app/tns_modules/data/observable/observable.js:155:23)
JS: ERROR CONTEXT:
JS: [object Object]
07-04 10:23:06.070 10809 10809 W System.err:     com.tns.Runtime.callJSMethodNative(Native Method)
07-04 10:23:06.070 10809 10809 W System.err:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861)
07-04 10:23:06.070 10809 10809 W System.err:     com.tns.Runtime.callJSMethodImpl(Runtime.java:726)
07-04 10:23:06.070 10809 10809 W System.err:     com.tns.Runtime.callJSMethod(Runtime.java:712)
07-04 10:23:06.070 10809 10809 W System.err:     com.tns.Runtime.callJSMethod(Runtime.java:693)
07-04 10:23:06.070 10809 10809 W System.err:     com.tns.Runtime.callJSMethod(Runtime.java:683)
07-04 10:23:06.071 10809 10809 W System.err:     com.tns.Runtime.callJSMethodNative(Native Method)
07-04 10:23:06.071 10809 10809 W System.err:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861)
07-04 10:23:06.071 10809 10809 W System.err:     com.tns.Runtime.callJSMethodImpl(Runtime.java:726)
07-04 10:23:06.071 10809 10809 W System.err:     com.tns.Runtime.callJSMethod(Runtime.java:712)
07-04 10:23:06.071 10809 10809 W System.err:     com.tns.Runtime.callJSMethod(Runtime.java:693)
07-04 10:23:06.071 10809 10809 W System.err:     com.tns.Runtime.callJSMethod(Runtime.java:683)
07-04 10:23:06.075 10809 10809 W System.err:    at com.tns.Runtime.callJSMethodNative(Native Method)
07-04 10:23:06.075 10809 10809 W System.err:    at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861)
07-04 10:23:06.075 10809 10809 W System.err:    at com.tns.Runtime.callJSMethodImpl(Runtime.java:726)
07-04 10:23:06.075 10809 10809 W System.err:    at com.tns.Runtime.callJSMethod(Runtime.java:712)
07-04 10:23:06.076 10809 10809 W System.err:    at com.tns.Runtime.callJSMethod(Runtime.java:693)
07-04 10:23:06.076 10809 10809 W System.err:    at com.tns.Runtime.callJSMethod(Runtime.java:683)

1 个答案:

答案 0 :(得分:0)

解决了这个问题。我没有在这个代码依赖的android模拟器上安装一个软件包,这就是为什么它抱怨它缺少活动。