Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

New Forums: Nexus Player | Nexus 9
test: Reply
 
LinkBack Thread Tools
Old July 9th, 2013, 06:11 AM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Jan 2013
Posts: 11
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default java.lang.IllegalStateException: Could not execute method

Hi,

I'm not very experienced in Android and I've taken over someone else's work and have been asked to implement in billing v3.

I have debugged the code and have located the issue here

[HIGH]//IF THE BUTTON IS VISIBLE, AND CLICKED, PURCHASE CALCULATOR
public void unlockCalculators(View v) {
String payload = "";
mHelper.launchPurchaseFlow(this, SKU_riskCalc, RC_REQUEST,
mPurchaseFinishedListener, payload); <---- LINE 250
Log.d("BP_EXPERT", "PURCHASE RISK CALC");

}[/HIGH]

Here is where the mPurchasedListener is defined

[HIGH] IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener()
{
@Override
public void onIabPurchaseFinished(IabResult result, Purchase purchase)
{
Log.d(TAG, "Purchase finished: " + result + ", purchase: " + purchase);
if (result.isFailure()) {
complain("Error purchasing: " + result);
}
if (!verifyDeveloperPayload(purchase)) {
complain("Error purchasing. Authenticity verification failed.");
return;

}
else if (purchase.getSku().equals(SKU_riskCalc)){

//UPDATE SHARED PREFERENCES HERE...
SharedPreferences prefs = getSharedPreferences("BloodPressure",MODE_PRIVATE) ;
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean("purchased_calcs", true);
edit.commit();
Log.d("BP_EXPERT", "PURCHASING RISK CALC");
//SELECT CORRECT LAYOUT AFTER PURCHASE
createStuff();
}
else if (purchase.getSku().equals(SKU_all)){

//UPDATE SHARED PREFERENCES HERE...
SharedPreferences prefs = getSharedPreferences("BloodPressure",MODE_PRIVATE) ;
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean("purchased_all", true);
edit.commit();
Log.d("BP_EXPERT", "PURCHASING ALL CONTENT");
//SELECT CORRECT LAYOUT AFTER PURCHASE
createStuff();
}
Log.d(TAG, "Purchase successful.");
}
};
[/HIGH]


When the app enters the launch purchase flow is when its forced closed. If anyone has any ideas as to what might be the problem I'd really appreciate it.
I've come across this problem, I'm not quite sure what is causing it, when I click on the button I get the following in my logcat

[HIGH]7-09 11:48:14.495: E/AndroidRuntime(1702): FATAL EXCEPTION: main
07-09 11:48:14.495: E/AndroidRuntime(1702): java.lang.IllegalStateException: Could not execute method of the activity
07-09 11:48:14.495: E/AndroidRuntime(1702): at android.view.View$1.onClick(View.java:2072)
07-09 11:48:14.495: E/AndroidRuntime(1702): at android.view.View.performClick(View.java:2408)
07-09 11:48:14.495: E/AndroidRuntime(1702): at android.view.View$PerformClick.run(View.java:8817)
07-09 11:48:14.495: E/AndroidRuntime(1702): at android.os.Handler.handleCallback(Handler.java:587 )
07-09 11:48:14.495: E/AndroidRuntime(1702): at android.os.Handler.dispatchMessage(Handler.java:92 )
07-09 11:48:14.495: E/AndroidRuntime(1702): at android.os.Looper.loop(Looper.java:144)
07-09 11:48:14.495: E/AndroidRuntime(1702): at android.app.ActivityThread.main(ActivityThread.jav a:4937)
07-09 11:48:14.495: E/AndroidRuntime(1702): at java.lang.reflect.Method.invokeNative(Native Method)
07-09 11:48:14.495: E/AndroidRuntime(1702): at java.lang.reflect.Method.invoke(Method.java:521)
07-09 11:48:14.495: E/AndroidRuntime(1702): at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:858)
07-09 11:48:14.495: E/AndroidRuntime(1702): at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:616)
07-09 11:48:14.495: E/AndroidRuntime(1702): at dalvik.system.NativeStart.main(Native Method)
07-09 11:48:14.495: E/AndroidRuntime(1702): Caused by: java.lang.reflect.InvocationTargetException
07-09 11:48:14.495: E/AndroidRuntime(1702): at com.bpxpert.bloodpressure.CalculatorRisk.unlockCal culators(CalculatorRisk.java:250)
07-09 11:48:14.495: E/AndroidRuntime(1702): at java.lang.reflect.Method.invokeNative(Native Method)
07-09 11:48:14.495: E/AndroidRuntime(1702): at java.lang.reflect.Method.invoke(Method.java:521)
07-09 11:48:14.495: E/AndroidRuntime(1702): at android.view.View$1.onClick(View.java:2067)
07-09 11:48:14.495: E/AndroidRuntime(1702): ... 11 more
07-09 11:48:14.495: E/AndroidRuntime(1702): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityReco rd@462b6c10 is not valid; is your activity running?
07-09 11:48:14.495: E/AndroidRuntime(1702): at android.view.ViewRoot.setView(ViewRoot.java:509)
07-09 11:48:14.495: E/AndroidRuntime(1702): at android.view.WindowManagerImpl.addView(WindowManag erImpl.java:177)
07-09 11:48:14.495: E/AndroidRuntime(1702): at android.view.WindowManagerImpl.addView(WindowManag erImpl.java:91)
07-09 11:48:14.495: E/AndroidRuntime(1702): at android.view.Window$LocalWindowManager.addView(Win dow.java:424)
07-09 11:48:14.495: E/AndroidRuntime(1702): at android.app.Dialog.show(Dialog.java:241)
07-09 11:48:14.495: E/AndroidRuntime(1702): at com.bpxpert.bloodpressure.CalculatorRisk.alert(Cal culatorRisk.java:382)
07-09 11:48:14.495: E/AndroidRuntime(1702): at com.bpxpert.bloodpressure.CalculatorRisk.complain( CalculatorRisk.java:374)
07-09 11:48:14.495: E/AndroidRuntime(1702): at com.bpxpert.bloodpressure.CalculatorRisk$3.onIabPu rchaseFinished(CalculatorRisk.java:277)
07-09 11:48:14.495: E/AndroidRuntime(1702): at com.bpxpert.bloodpressure.util.IabHelper.launchPur chaseFlow(IabHelper.java:376)
07-09 11:48:14.495: E/AndroidRuntime(1702): at com.bpxpert.bloodpressure.util.IabHelper.launchPur chaseFlow(IabHelper.java:324)
07-09 11:48:14.495: E/AndroidRuntime(1702): ... 15 more
07-09 11:48:14.505: W/ActivityManager(105): Force finishing activity com.bpxpert.bloodpressure/.BloodPressureActivity[/HIGH]


Thanks in advance!

Advertisements
GaryDoo is offline  
Reply With Quote
sponsored links
Reply
Tags
illegal state exception, in app purchase


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:24 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.