0
大家好我在這個網站上找到了關於putEtras的一個答案,但是當我嘗試使用它時,我的應用程序崩潰了,我嘗試了一切,並沒有發現錯誤。我確信它是一些小事,但我無法檢測它是什麼,所以我再次詢問這裏尋求幫助我......PutEtras崩潰活動援助
第一類:
package com.orion.peky.thetapgame;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.widget.TextView;
import com.google.android.gms.ads.*;
public class Game extends Activity {
TextView tekst, vrijeme;
int brojac=0, provjera=0;
CountDownTimer Count;
Intent i =new Intent(Game.this,Score.class);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game);
tekst=(TextView)findViewById(R.id.tekst);
vrijeme=(TextView)findViewById(R.id.vrijeme);
/*AdView adView=(AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);*/
Count = new CountDownTimer(10000, 1) {
public void onTick(long millisUntilFinished) {
int seconds = (int) ((millisUntilFinished/1000));
vrijeme.setText(seconds + "." + millisUntilFinished % 1000);
}
public void onFinish(){
i.putExtra("prijenos",brojac);
startActivity(i);
finish();
}};
}
public void broji(View view){
if(provjera==0){
Count.start();
brojac++;
provjera++;
tekst.setText("Tapped " + brojac + " times");
}else {
brojac++;
tekst.setText("Tapped " + brojac + " times");
}
}
}
,第2活動:
package com.orion.peky.thetapgame;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
public class Score extends Activity {
int primljeno=1;
TextView prikazati=(TextView)findViewById(R.id.prikazbodova);
Bundle dodatak;
Intent inte=getIntent();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_score);
dodatak=inte.getExtras();
primljeno=dodatak.getInt("prijenos");
prikazati.setText("You tapped "+primljeno+" times");
}
}
我已經找到索姆e答案如下: How to put Extras to different activity? 但開始第二項活動仍然存在一些問題。 我知道adView已被註銷,但我不想製造假裝! 請不要將其標記爲重複,因爲它不是! :D
是的一個錯誤,而不是錯誤,STIL崩潰...... – Peky5 2014-10-02 15:05:26
發表新的堆棧跟蹤 – Blackbelt 2014-10-02 15:08:33
,我可以看到它說無法實例化活動componentinfo {COM .orion.peky.thetapgame/com.orion.peky.thetapgame.score和由:android.app.activity.findviewbyid java.lang.nullpointerexcetpion activity.java – Peky5 2014-10-02 16:31:09