2017-04-03 2 views
-5

Ich wurde von diesem Problem abgehört und ich habe eine schnelle Lösung zu diesem Problem. Bitte hilf mir. So stürzt ich im Moment jedes Mal ab, wenn ich einige neue Codes einfüge, die ich online finde. [P.S. Ich bin ein newb in Android Programmierung]Meine Android-Anwendung hörte plötzlich auf zu arbeiten

Das ist mein AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="birada1.tulungatung.ph.myapplication2"> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/chess_icon" 
    android:label="@string/app_name" 
    android:roundIcon="@mipmap/ic_launcher_round" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity android:name=".MainActivity"> 

     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
</application> 

</manifest> 

ich einige kleinere Änderungen an MainActivity.java

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.Button; 

public class MainActivity extends Activity implements View.OnClickListener { 

private Button btn; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    Button one = (Button) findViewById(R.id.button2); 
    Button two = (Button) findViewById(R.id.button3); 
    Button three = (Button) findViewById(R.id.button4); 

    one.setOnClickListener(this); 
    two.setOnClickListener(this); 
    three.setOnClickListener(this); 
} 


@Override 
public void onClick(View view) { 
    switch (view.getId()) { 

     case R.id.button2: 
      Intent intenthistory = new Intent(this, ChessHistoryActivity.class); 
      startActivity(intenthistory); 
      // do your code 
      break; 

     case R.id.button3: 
      Intent intenthistory2 = new Intent(this, LearnChessActivity.class); 
      startActivity(intenthistory2); 
      break; 
     case R.id.button4: 
      Intent intenthistory3 = new Intent(this, GrandmastersActivity.class); 
      startActivity(intenthistory3); 
      break; 


     default: 
    } 

} 
} 

activity_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical"> 


<ImageView 
android:id="@+id/img_view3" 
android:layout_width="wrap_content" 
android:layout_height="95dp" 
android:contentDescription="@string/hellow" 
app:srcCompat="@drawable/boom" /> 

<Button 
android:id="@+id/button2" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:background="@color/colorPrimaryDark" 
android:onClick="btnClick1" 
android:text="@string/c_history" /> 

<ImageView 
android:id="@+id/img_view4" 
android:layout_width="wrap_content" 
android:layout_height="101dp" 
android:contentDescription="@string/hellow" 
app:srcCompat="@drawable/chess_moves_three" /> 

<Button 
android:id="@+id/button3" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:onClick="btnClick2" 
android:background="@color/colorPrimaryDark" 
android:text="@string/c_moves" /> 

<ImageView 
android:id="@+id/imageView5" 
android:layout_width="wrap_content" 
android:layout_height="113dp" 
android:contentDescription="@string/hellow" 
app:srcCompat="@drawable/grandmasters" /> 

<Button 
android:id="@+id/button4" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/colorPrimaryDark" 
android:onClick="btnClick3" 
android:text="@string/c_grandmasters" /> 
</LinearLayout> 
+0

die roten Protokolle prüfen und hier posten. – TruongHieu

+0

fügen Sie Ihre Aktivität zu Ihrem Manifest hinzu. Ihr Absturz wegen Absichtsaktivität ist noch nicht registriert – ZeroOne

Antwort

0

Haben Sie erklärt ChessHistoryActivity/LernenSchachAktivität/GroßmeisterA ctivity in AndroidManifest.xml? wenn nicht

<activity android:name=".ChessHistoryActivity" 
      android:launchMode="singleTask" /> 

<activity android:name=".LearnChessActivity" 
      android:launchMode="singleTask" /> 

<activity android:name=".GrandmastersActivity" 
      android:launchMode="singleTask" /> 
1

hinzufügen Entfernen Sie Ihre Anwendung Tag aus manifest und fügen Sie diese Anwendung Tag und versuchen Sie es Ihr Problem gelöst werden.

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/chess_icon" 
    android:label="@string/app_name" 
    android:roundIcon="@mipmap/ic_launcher_round" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity android:name=".MainActivity"> 

     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity android:name=".ChessHistoryActivity"/> 
    <activity android:name=".LearnChessActivity"/> 
    <activity android:name=".GrandmastersActivity"/> 
</application> 
0
  1. Erste hinzufügen ChessHistoryActivity.java, LearnChessActivity.java und GrandmastersActivity.java Klassen in Ihre Java-source Ordner (If not added yet).

    Folder:./app/src/main/java/birada1.tulungatung.ph.myapplication2/

  2. Deklarieren ChessHistoryActivity, LearnChessActivity und GrandmastersActivity in der AndroidManifest.xml Datei.

    <?xml version="1.0" encoding="utf-8"?> 
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
        package="birada1.tulungatung.ph.myapplication2"> 
    
        <application 
         android:allowBackup="true" 
         android:icon="@mipmap/chess_icon" 
         android:label="@string/app_name" 
         android:roundIcon="@mipmap/ic_launcher_round" 
         android:supportsRtl="true" 
         android:theme="@style/AppTheme"> 
    
         <activity android:name=".MainActivity"> 
          <intent-filter> 
           <action android:name="android.intent.action.MAIN" /> 
    
           <category android:name="android.intent.category.LAUNCHER" /> 
          </intent-filter> 
         </activity> 
    
         <activity android:name=".ChessHistoryActivity" /> 
         <activity android:name=".LearnChessActivity" /> 
         <activity android:name=".GrandmastersActivity" /> 
    
        </application> 
    </manifest> 
    

Hope this helfen ~

Verwandte Themen