スプラッシュアクティビティを正常に起動した後、私のアプリはStartingPointの2番目のアクティビティに移動できません。アプリは「残念ながらTheNewBostonは機能しなくなった」と言って終了する。Androidアプリケーションがスプラッシュアクティビティの後にアクティビティを起動できない
関連ファイルを添付しています。誰かがこれで私を助けることを願っています。 StartingPoint.java
package com.example.thenewboston;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class StartingPoint extends Activity {
int counter;
Button add,sub;
TextView display;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_starting_point);
counter=0;
add=(Button)findViewById(R.id.addButton);
sub=(Button)findViewById(R.id.subButton);
display=(TextView) findViewById(R.id.display);
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
counter++;
display.setText("Your total is = " + counter);
}
});
sub.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
counter--;
display.setText("Your total is = " + counter);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.starting_point, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Splash.java
package com.example.thenewboston;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class Splash extends Activity{
@Override
public void onCreate(Bundle TV) {
// TODO Auto-generated method stub
super.onCreate(TV);
setContentView(R.layout.splash);
Thread timer = new Thread(){
public void run(){
try{
sleep(5000);
}catch(InterruptedException e){
e.printStackTrace();
}finally{
Intent openStatingPoint= new Intent("com.thenewboston.StartingPoint");
startActivity(openStatingPoint);
}
}
};
timer.start();
}
}
たManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.thenewboston"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="23"
android:targetSdkVersion="23" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".StartingPoint"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.thenewboston.StartingPoint" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
logcatを追加します。クラッシュの –
@Sumeet Shahはインテントを置き換えます。openStatingPoint = new Intent( "com.thenewboston.StartingPoint");インテントi =新しいインテント( this 、StartingPoint.class); – Nisarg