2010-12-11 26 views
0

je veux appeler makePayment(); Je veux exécuter automatiquement ...... Ce est mon codeappel Android makePayment comment

package com.musicdownloader; 


import com.fortumo.android.PaymentActivity; 
import com.musicdownloader.R; 

import android.content.Intent; 
import android.net.Uri; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.Button; 
import android.widget.EditText; 
import android.widget.Toast; 
import android.view.View.OnClickListener; 

public class app extends PaymentActivity { 

     public void onCreate(Bundle savedInstanceState) { 
      makePayment();  
      super.onCreate(savedInstanceState); 
       setContentView(R.layout.main); 

       Button payButton = (Button) findViewById(R.id.Next); 
       payButton.setOnClickListener(new OnClickListener() { 
        public void onClick(View v) { 
          final EditText q = (EditText) findViewById(R.id.q); 
          Intent i = new Intent("android.intent.action.VIEW", Uri.parse("http://www.google.com/search?q=" +q.getText().toString())); 
          startActivity(i); 

         } 
       }); 

     } 
     @Override 
     protected void onPaymentCanceled(String product) { 
       Toast.makeText(this, "Payment canceled by user", Toast.LENGTH_SHORT).show(); 
     } 

     @Override 
     protected void onPaymentFailed(String product) { 
       Toast.makeText(this, "Payment failed", Toast.LENGTH_SHORT).show(); 
     } 

     @Override 
     protected void onPaymentPending(long messageId, String product) { 
       Toast.makeText(this, "Payment not confirmed", Toast.LENGTH_SHORT).show(); 
     } 

     @Override 
     protected void onPaymentSuccess(String product) { 
       Toast.makeText(this, "Payment received", Toast.LENGTH_SHORT).show(); 
     } 

Comment appeler ?? Merci

+0

btW: il est recommandé d'appeler habituellement super.onCreate (savedInstanceState); d'abord, puis vos propres trucs personnalisés. Vous appelez déjà makePayment() dans votre onCreate - où est le problème? –

+0

@ Mathias, en fait, dans Android, ce n'est pas seulement une bonne pratique, c'est nécessaire. Je suis sûr que ça va exploser si vous ne l'appelez pas en premier ... –

Répondre

1

Vous devriez l'appeler dans votre méthode onStart, après vous avez appelé super.onStart.