无法呼叫活动

时间:2017-12-06 09:24:32

标签: android

我想从菜单调用一个活动,但当我按下按钮调用调谐器活动时,应用程序就退出了。当呼叫另一个活动成功时

这是调谐器活动

public class TunerActivity extends AppCompatActivity {
    private static final String TAG = TunerActivity.class.getSimpleName();
    private TunerFragment tunerFragment;
    private PitchFragment pitchFragment;
    private boolean showCancel;

    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        showCancel = false;
        setContentView(R.layout.tuner_activity);
        Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        tunerFragment = new TunerFragment();
        getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, tunerFragment, TunerFragment.TAG).commit();
        setTimedNotification();
    }
    ....
}

这是仪表板活动(菜单)

public class DashboardActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.dashboard_layout);


        // Dashboard Tombol berita
        Button btn_tuner = (Button) findViewById(R.id.btn_tuner);

        // Dashboard Tombol teman
        Button btn_midi = (Button) findViewById(R.id.btn_midi);

        // Dashboard Tombol info
        Button btn_info = (Button) findViewById(R.id.btn_info);

        // Dashboard Tombol helo
        Button btn_help = (Button) findViewById(R.id.btn_help);


        // Menangkap klik event tombol tuner

        btn_tuner.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                // Menampilkan screen berita
                Intent i = new Intent(DashboardActivity.this, TunerActivity.class);
                startActivity(i);
            }
        });

       // Menangkap klik event tombol teman
        btn_midi.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                // Menampilkan screen teman
                Intent i = new Intent(getApplicationContext(), TemanActivity.class);
                startActivity(i);
            }
        });

        // Menangkap klik event tombol pesan
        btn_info.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                // Menampilkan screen pesan
                Intent i = new Intent(getApplicationContext(), PesanActivity.class);
                startActivity(i);
            }
        });

        // Menangkap klik event tombol tempat
        btn_help.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                // Menampilkan screen tempat
                Intent i = new Intent(getApplicationContext(), TempatActivity.class);
                startActivity(i);
            }
        });

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.dashboard, menu);
        return true;
    }

}

这是清单 我被宣布为所有活动

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="firman.salatigadev.dashboard"
    android:versionCode="1"
    android:versionName="1.0"
    tools:ignore="GradleOverrides">

    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.INTERNET" />

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="27"
        tools:ignore="OldTargetApi" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        tools:ignore="AllowBackup,GoogleAppIndexingWarning">
        <activity
            android:name="firman.salatigadev.dashboard.DashboardActivity"
            android:label="@string/app_name"
            android:configChanges="orientation|keyboardHidden|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <receiver android:name=".NotificationPublishReceiver"/>

        <activity
            android:name=".TunerActivity">
        </activity>

        <activity
            android:name="firman.salatigadev.dashboard.BeritaActivity" >
        </activity>

        <activity
            android:name="firman.salatigadev.dashboard.TemanActivity" >
        </activity>

        <activity
            android:name="firman.salatigadev.dashboard.PesanActivity" >
        </activity>

        <activity
            android:name="firman.salatigadev.dashboard.TempatActivity" >
        </activity>

        <activity
            android:name="firman.salatigadev.dashboard.AcaraActivity" >
        </activity>

        <activity
            android:name="firman.salatigadev.dashboard.FotoActivity" >
        </activity>

    </application>

</manifest>

意图有什么不对?有人知道吗?

0 个答案:

没有答案