2010-12-11 45 views
0

想打電話makePayment();我要自動運行...... 這是我的代碼的Android電話makePayment我如何

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(); 
     } 

如何稱呼它? 謝謝

+0

btW:通常會調用super.onCreate(savedInstanceState);首先,然後你自己定製的東西。您已經在onCreate中調用了makePayment() - 問題到底在哪裏? – 2010-12-11 13:21:04

+0

@Mathias,實際上,在Android中,這不僅僅是良好的做法,它是必需的。我很肯定,如果你不先打電話,它會炸燬。 – 2010-12-16 18:22:01

回答

1

你應該把它在你的onStart方法,後你叫super.onStart