-3
別のアクティビティに文字列を送信する必要があります。このデータを別のアクティビティに送信する方法
long timeSpent = System.currentTimeMillis() - initialTime;
timeSpent = (long) (timeSpent/1000.0);
String string = "Game Over! Time spent " + String.valueOf(timeSpent) + "s";
私はこのコードを使用しますが、間違っています。
Intent intent = new Intent();
intent.putExtra("timespeent", timeSpent);
は、質問を投稿する前にグーグルを使って、小さな検索をしてください、このようにあなたのコードを変更する必要があります! –
Intentのクラスを次のようにします。 Intent intent = new Intent(currentclass.this、NextClass.class);intent.putExtra( "timespent"、string); startActivity(インテント); –