Partage
  • Partager sur Facebook
  • Partager sur Twitter

[ANDROID] In app billing...

    3 janvier 2013 à 17:36:14

    Bonjour à tous.

    J'essaie aujourd'hui de mettre en place le système in app billing V3 et j'ai pas mal de soucis.
    A l'heure actuelle, celui qui pose le plus de problème est un message d'erreur :

    "Unable to start service Intent {act=com.android.vending.billing.InAppBillingService.BIND} : not found"

    Petite précision : l'application a été faite en Windev Mobile et le package en Java.

    Je n'ai jamais programmé d'appli android en Java (et n'en avait pas besoin pour l'instant, WinDev me satisfaisait pour mes petites applis persos.)

    J'ai beau tourné le problème dans tout les sens, je m'y prends sans doute mal.

    Voici le code de ma classe :

    package com.pack.packbilling;
    
    import com.android.vending.billing.IInAppBillingService;
    import android.app.Activity;
    import android.content.ComponentName;
    import android.content.Context;
    import android.content.Intent;
    import android.content.ServiceConnection;
    import android.os.Bundle;
    import android.os.IBinder;
    import android.util.Log;
    
    
    public class Pack_Payment extends Activity {
    	
    	static final String SKU_Var1 = "1";
    	static final String SKU_Var2 = "2";
    	static final String SKU_Var3 = "3";
    	static final String SKU_Var4 = "4";
    	
    	// The helper object
    	IabHelper mHelper;
    	
    	IInAppBillingService mService;
    	
    	public void onCreate(Bundle savedInstanceState) {
    		
    		super.onCreate(savedInstanceState);
    		
    		ServiceConnection mServiceConn = new ServiceConnection() {
    			   @Override
    			   public void onServiceDisconnected(ComponentName name) {
    			       mService = null;
    			   }
    
    			   @Override
    			   public void onServiceConnected(ComponentName name, 
    			      IBinder service) {
    			       mService = IInAppBillingService.Stub.asInterface(service);
    			   }
    			};
    		
    		bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"), mServiceConn, Context.BIND_AUTO_CREATE);
    		
    	   alert("4");
    	   String base64EncodedPublicKey = "clé de mon appli";
    	   alert("5");
    	   
    	   // Compute your public key and store it in base64EncodedPublicKey
    	   mHelper = new IabHelper(this, base64EncodedPublicKey);
    	   mHelper.enableDebugLogging(true);
    	   alert("6");
    	   
    	   mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
    		   public void onIabSetupFinished(IabResult result) {
    		      if (!result.isSuccess()) {
    		         // Oh noes, there was a problem.
    		    	  alert("7");
    		    	  return;
    		      }            
    		         // Hooray, IAB is fully set up! 
    		      	alert("8");
    		   }
    		});
    	   alert("8 bis");
    	}
    	
        // We're being destroyed. It's important to dispose of the helper here!
        @Override
        public void onDestroy() {
            // very important:
            if (mHelper != null) mHelper.dispose();
            mHelper = null;
            alert("9");
        }
    	
    	public void Start_Payment(String _IDProduit){
    		alert("10");
    		mHelper.launchPurchaseFlow(this, _IDProduit, 10001, mPurchaseFinishedListener);
    		alert("11");
    	}
    	
        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        	alert("Y - onActivityResult(" + requestCode + "," + resultCode + "," + data);
    
            // Pass on the activity result to the helper for handling
            if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
                // not handled, so handle it ourselves (here's where you'd
                // perform any handling of activity results not related to in-app
                // billing...
                super.onActivityResult(requestCode, resultCode, data);
            }
            else {
            	alert("Z - onActivityResult handled by IABUtil.");
            }
        }
    	
        // Callback for when a purchase is finished
        IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
            public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
            	alert("12");
                if (result.isFailure()) {
                    // Oh noes!
                	alert("13");
                    return;
                }
                alert("14");
                // Purchase successful
                if (purchase.getSku().equals(SKU_Var1)) {
                    // bought 1/4 tank of gas. So consume it.
                    mHelper.consumeAsync(purchase, mConsumeFinishedListener);
                }
                else if (purchase.getSku().equals(SKU_Var2)) {
                	mHelper.consumeAsync(purchase, mConsumeFinishedListener);
                }
                else if (purchase.getSku().equals(SKU_Var3)) {
                	mHelper.consumeAsync(purchase, mConsumeFinishedListener);
                }
                else if (purchase.getSku().equals(SKU_Var4)) {
                	mHelper.consumeAsync(purchase, mConsumeFinishedListener);
                }
            }
        };
        
        // Called when consumption is complete
        IabHelper.OnConsumeFinishedListener mConsumeFinishedListener = new IabHelper.OnConsumeFinishedListener() {
            public void onConsumeFinished(Purchase purchase, IabResult result) {
            	alert("15");
                if (result.isSuccess()) {
                    alert("16");
                }
                else {
                    alert("17");
                }
            }
        };
        
        static void alert(String _Message) {
        	Log.e("MonApp - ",_Message);
        }
    }
    


    Et voici le code de mon manifest :
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="fr.monAp.monAp" android:versionCode="79" android:versionName="0.0.1.0" android:installLocation="auto">
    <application android:label="@string/app_name" android:icon="@drawable/i_c_o_n_e________1">
    <activity android:name=".wdgen.GWDPiConfident$WDLanceur" android:label="@string/app_name" android:theme="@android:style/Theme.Translucent">
    <intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
    </activity>
    <activity android:name=".wdgen.GWDFFEN_Login$WDActiviteFenetre" android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme" android:screenOrientation="portrait"/>
    <activity android:name=".wdgen.GWDFFEN_Service_Client$WDActiviteFenetre" android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme" android:screenOrientation="portrait"/>
    <activity android:name=".wdgen.GWDFFEN_Message$WDActiviteFenetre" android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme" android:screenOrientation="portrait"/>
    <activity android:name=".wdgen.GWDFFEN_Commentaire$WDActiviteFenetre" android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme" android:screenOrientation="portrait"/>
    <activity android:name=".wdgen.GWDFFEN_Credit$WDActiviteFenetre" android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme" android:screenOrientation="portrait"/>
    <activity android:name=".wdgen.GWDFFEN_HTML$WDActiviteFenetre" android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme" android:screenOrientation="portrait"/>
    <activity android:name=".wdgen.GWDFFEN_Themes$WDActiviteFenetre" android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme" android:screenOrientation="portrait"/>
    <activity android:name=".wdgen.GWDFFEN_Informations$WDActiviteFenetre" android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme" android:screenOrientation="portrait"/>
    <activity android:name=".wdgen.GWDFFEN_Reglages$WDActiviteFenetre" android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme" android:screenOrientation="portrait"/>
    <activity android:name=".wdgen.GWDFFEN_Mes_Infos$WDActiviteFenetre" android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme" android:screenOrientation="portrait"/>
    <activity android:name=".wdgen.GWDFFEN_Historique_Achats$WDActiviteFenetre" android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme" android:screenOrientation="portrait"/>
    <activity android:name=".wdgen.GWDFFEN_Nouveau_Compte$WDActiviteFenetre" android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme" android:screenOrientation="portrait"/>
    <activity android:name=".wdgen.GWDFFEN_Liste_Situation$WDActiviteFenetre" android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme" android:screenOrientation="portrait"/>
    <activity android:name=".wdgen.GWDFFEN_Liste_Conversation$WDActiviteFenetre" android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme" android:screenOrientation="portrait"/>
    <activity android:name=".wdgen.GWDFFEN_Bienvenue$WDActiviteFenetre" android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme" android:screenOrientation="portrait"/>
    <activity android:name="com.pack.packbilling">
    </activity>
    </application>
    <uses-sdk android:minSdkVersion="3"/>
    <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="com.android.vending.BILLING"/>
    <uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
    </manifest>
    


    Par ailleurs, est-il possible que cela ne fonctionne pas sur le simulateur android ?
    Merci beaucoup et bonne soirée

    Cordialement,

    Skahrz
    • Partager sur Facebook
    • Partager sur Twitter
    Le manager pragmatique ne cherchera pas le "quoi" de l'erreur, mais le "pourquoi" de celle-ci

    [ANDROID] In app billing...

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown