Android应用内结算购买活动正在崩溃该应用。
我有一个应用内结算活动,购买了1个月内删除广告的订阅。
但是当我点击调用结算活动的删除广告按钮时, 应用程序正在崩溃。
这是我的logcat输出:
.content
{
padding-top: 1em;
padding-bottom: 1em;
background-color: #fec321;
text-align: center;
overflow: hidden;
}
.content .photo
{
position: relative;
border: solid .75em #ffffff;
-webkit-box-shadow: 2px 2px 2px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 2px 2px 2px 0px rgba(0,0,0,0.75);
box-shadow: 2px 2px 2px 0px rgba(0,0,0,0.75);
display: inline-block;
}
.content picture, .content img, .content .description span
{
position: relative;
width: 14em;
height: 14em;
display: block;
}
.content .description
{
position: relative;
border: solid .75em #ffffff;
-webkit-box-shadow: 2px 2px 2px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 2px 2px 2px 0px rgba(0,0,0,0.75);
box-shadow: 2px 2px 2px 0px rgba(0,0,0,0.75);
display: inline-block;
}
这是我的订阅按钮活动:
12-18 02:07:51.872: E/chromium(694): [ERROR:browser_gpu_channel_host_factory.cc(258)] Failed to init browser shader disk cache.
12-18 02:07:51.883: E/libEGL(694): validate_display:255 error 3008 (EGL_BAD_DISPLAY)
12-18 02:07:51.888: W/cr.media(694): Requires BLUETOOTH permission
12-18 02:07:51.907: W/art(694): Attempt to remove non-JNI local reference, dumping thread
12-18 02:07:51.914: W/AwContents(694): onDetachedFromWindow called when already detached. Ignoring
12-18 02:07:52.278: W/VideoCapabilities(694): Unrecognized profile 2130706433 for video/avc
12-18 02:07:52.310: I/VideoCapabilities(694): Unsupported profile 4 for video/mp4v-es
12-18 02:07:52.316: I/OMXClient(694): Using client-side OMX mux.
12-18 02:07:52.396: I/Ads(694): Starting ad request.
12-18 02:07:52.401: I/Ads(694): Please set theme of AdActivity to @android:style/Theme.Translucent to enable transparent background interstitial ad.
12-18 02:07:52.408: I/Ads(694): Starting ad request.
12-18 02:07:52.411: I/Ads(694): Please set theme of AdActivity to @android:style/Theme.Translucent to enable transparent background interstitial ad.
12-18 02:07:52.420: D/OpenGLRenderer(694): Use EGL_SWAP_BEHAVIOR_PRESERVED: true
12-18 02:07:52.439: D/billing(694): In app billing is set up
12-18 02:07:52.542: I/OpenGLRenderer(694): Initialized EGL, version 1.4
12-18 02:07:54.634: D/AndroidRuntime(694): Shutting down VM
12-18 02:07:54.636: E/AndroidRuntime(694): FATAL EXCEPTION: main
12-18 02:07:54.636: E/AndroidRuntime(694): Process: com.ifreedomapp.v3, PID: 694
12-18 02:07:54.636: E/AndroidRuntime(694): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Activity.startIntentSenderForResult(android.content.IntentSender, int, android.content.Intent, int, int, int)' on a null object reference
12-18 02:07:54.636: E/AndroidRuntime(694): at com.ifreedom.util.IabHelper.launchPurchaseFlow(IabHelper.java:431)
12-18 02:07:54.636: E/AndroidRuntime(694): at com.ifreedom.util.IabHelper.launchPurchaseFlow(IabHelper.java:347)
12-18 02:07:54.636: E/AndroidRuntime(694): at com.ifreedom.StatusActivity$4.onClick(StatusActivity.java:379)
12-18 02:07:54.636: E/AndroidRuntime(694): at android.view.View.performClick(View.java:5204)
12-18 02:07:54.636: E/AndroidRuntime(694): at android.view.View$PerformClick.run(View.java:21153)
12-18 02:07:54.636: E/AndroidRuntime(694): at android.os.Handler.handleCallback(Handler.java:739)
12-18 02:07:54.636: E/AndroidRuntime(694): at android.os.Handler.dispatchMessage(Handler.java:95)
12-18 02:07:54.636: E/AndroidRuntime(694): at android.os.Looper.loop(Looper.java:148)
12-18 02:07:54.636: E/AndroidRuntime(694): at android.app.ActivityThread.main(ActivityThread.java:5417)
12-18 02:07:54.636: E/AndroidRuntime(694): at java.lang.reflect.Method.invoke(Native Method)
12-18 02:07:54.636: E/AndroidRuntime(694): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
12-18 02:07:54.636: E/AndroidRuntime(694): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-18 02:07:57.191: I/GAV3(694): Thread[GAThread,5,main]: No campaign data found.
这是setbilling函数:
bsubscribe.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (billing_error == "") {
if (!isSubscribed)
mHelper.launchPurchaseFlow(getParent(), SKU_SUBSCRIPTION, 9999, mPurchaseFinishedListener,"");
else
Toast.makeText(mContext, getResources().getString(R.string.already_subs), Toast.LENGTH_SHORT).show();
} else
Toast.makeText(mContext, "There's some error in billing : " + billing_error, Toast.LENGTH_LONG).show();
}
});
}
从活动的OnCreate调用设置结算。
当我点击删除广告按钮(bsubscribe)
时,应用程序崩溃了答案 0 :(得分:0)
很难准确地说明所提供的代码,但看起来getParent()
的调用在onClick
方法中返回null。然后在IabHelper.java
的第431行,您在空对象上调用startIntentSenderForResult
。