2017-07-27 4 views
0

Ich versuche, eine App zu erstellen, in der der Benutzer durch eine Reihe von "Menüs" navigiert, um auf Inhalte zuzugreifen.
I erstellt das Menü, das beim Öffnen der appProbleme beim Konfigurieren von Aktivitäten, die auf EditText-Benutzereingabe basieren

MainMenuActivity.java erscheint:

public class MainMenuActivity extends AppCompatActivity { 
ListView listView; 
ArrayAdapter<String> main_adapter; 
String[] main_menu = { 
     "1 INTRO", 
     "2 HELP", 
     "3 AROUND THE WORLD" 
}; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main_menu_layout); 
    listView = (ListView) findViewById(R.id.main_list); 
    main_adapter = new ArrayAdapter<>(this, R.layout.main_list_custom_layout, R.id.main_list_item, main_menu); 
    listView.setAdapter(main_adapter); 
} 

public void openNewActivity(View view) { 
    EditText main_edit_text = (EditText) findViewById(R.id.main_edit_text); 
    String answer = main_edit_text.getText().toString().trim(); 
    switch (answer) { 
     case "1": { 
      Intent intent = new Intent(this, IntroActivity.class); 
      startActivity(intent); 
      break; 
     } 
     case "2": { 
      Intent intent = new Intent(this, HelpActivity.class); 
      startActivity(intent); 
      break; 
     } 
     case "3": { 
      Intent intent = new Intent(this, AroundTheWorldActivity.class); 
      startActivity(intent); 
      break; 
     } 
     default: { 
      Intent intent = new Intent(getApplicationContext(), MainMenuActivity.class); 
      startActivity(intent); 
      break; 
     } 
    } 
} 

und I erstellt das Menü, das auf dem ersten Menü auf der Eingabe von „3“ (Fall 3) in die EditText erscheint .

AroundTheWorldActivity.java:

public class AroundTheWorldActivity extends Activity { 
    ListView listView; 
    ArrayAdapter<String> around_the_world_adapter; 
    String[] around_the_world_menu = { 
      "1 OVERVIEW", 
      "2 RECEIVING" 
    }; 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.around_the_world_layout); 
    listView = (ListView) findViewById(R.id.around_the_world_list); 
    around_the_world_adapter = new ArrayAdapter<>(this, R.layout.around_the_world_list_custom_layout, R.id.around_the_world_list_item, around_the_world_menu); 
    listView.setAdapter(around_the_world_adapter); 
} 

public void openNewActivity(View view) { 
    EditText around_the_world_edit_text = (EditText) findViewById(R.id.around_the_world_edit_text); 
    String answer = around_the_world_edit_text.getText().toString().trim(); 
    switch (answer) { 
     case "1": { 
      Intent atwintent = new Intent(this, AroundTheWorldOverviewActivity.class); 
      startActivity(atwintent); 
      break; 
     } 
     case "2": { 
      Intent atwintent = new Intent(this, ReceivingActivity.class); 
      startActivity(atwintent); 
      break; 
     }   
     default: { 
      Intent atwintent = new Intent(getApplicationContext(), AroundTheWorldActivity.class); 
      startActivity(atwintent); 
      break; 
     } 
    } 
} 

konfiguriert I die Aktivität, die "1" ist (Fall 1) im Sekundärmenü bei Eingabe öffnet.

AroundTheWorldOverviewActivity.java:

public class AroundTheWorldOverviewActivity extends Activity { 

     protected void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.around_the_world_overview_layout); 
     } 
    } 

around_the_world_overview_layout.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#000000" 
    > 
    <TextView 
     android:id="@+id/atw_overview_text" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fontFamily="sans-serif-smallcaps" 
     android:gravity="center_horizontal" 
     android:padding="16dp" 
     android:text="Around The World Overview Text" 
     android:textAppearance="?android:textAppearanceLarge" 
     android:textColor="#ffffff" 
     /> 
</RelativeLayout> 

ich in der Lage bin durch das zweite Menü zu navigieren, aber wenn ich die dritte Aktivität zuzugreifen versuchen, stoppt der App arbeiten /stürzt ab.

LogCat:

08-01 19:54:43.500 2220-2220/com.google.android.googlequicksearchbox:search 
I/MicroDetectionWorker: Micro detection mode: [mDetectionMode: [1]]. 
08-01 19:54:43.502 2220-2220/com.google.android.googlequicksearchbox:search 
I/AudioController: Using mInputStreamFactoryBuilder 
08-01 19:54:43.534 2220-4313/com.google.android.googlequicksearchbox:search I/MicroRecognitionRunner: Starting detection. 
08-01 19:54:43.540 2220-2324/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_starting [email protected] 
08-01 19:54:43.548 1365-4316/? I/AudioFlinger: AudioFlinger's thread 0xacf83540 ready to run 
08-01 19:54:43.562 2220-2324/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_started [email protected] 
08-01 19:54:43.567 2220-2324/com.google.android.googlequicksearchbox:search E/ActivityThread: Failed to find provider info for com.google.android.apps.gsa.testing.ui.audio.recorded 
08-01 19:54:43.569 2220-2324/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_close [email protected] 
08-01 19:54:43.573 2220-2220/com.google.android.googlequicksearchbox:search I/MicroDetectionWorker: onReady 
08-01 19:54:43.588 2220-4313/com.google.android.googlequicksearchbox:search I/MicroRecognitionRunner: Detection finished 
08-01 19:54:43.588 2220-4313/com.google.android.googlequicksearchbox:search W/ErrorReporter: reportError [type: 211, code: 524300]: Error reading from input stream 
08-01 19:54:43.590 2220-2492/com.google.android.googlequicksearchbox:search I/MicroRecognitionRunner: Stopping hotword detection. 
08-01 19:54:43.591 2220-4313/com.google.android.googlequicksearchbox:search W/ErrorProcessor: onFatalError, processing error from engine(4) 
                           com.google.android.apps.gsa.shared.speech.a.g: Error reading from input stream 
                            at com.google.android.apps.gsa.staticplugins.recognizer.i.a.a(SourceFile:342) 
                            at com.google.android.apps.gsa.staticplugins.recognizer.i.a$1.run(SourceFile:1367) 
                            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428) 
                            at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
                            at com.google.android.apps.gsa.shared.util.concurrent.a.ak.run(SourceFile:66) 
                            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
                            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
                            at java.lang.Thread.run(Thread.java:761) 
                            at com.google.android.apps.gsa.shared.util.concurrent.a.ad$1.run(SourceFile:85) 
                           Caused by: com.google.android.apps.gsa.shared.exception.GsaIOException: Error code: 393238 | Buffer overflow, no available space. 
                            at com.google.android.apps.gsa.speech.audio.Tee.g(SourceFile:2531) 
                            at com.google.android.apps.gsa.speech.audio.ap.read(SourceFile:555) 
                            at java.io.InputStream.read(InputStream.java:101) 
                            at com.google.android.apps.gsa.speech.audio.al.run(SourceFile:362) 
                            at com.google.android.apps.gsa.speech.audio.ak$1.run(SourceFile:471) 
                            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428) 
                            at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
                            at com.google.android.apps.gsa.shared.util.concurrent.a.ak.run(SourceFile:66) 
                            at com.google.android.apps.gsa.shared.util.concurrent.a.ax.run(SourceFile:139) 
                            at com.google.android.apps.gsa.shared.util.concurrent.a.ax.run(SourceFile:139) 
                            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)  
                            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)  
                            at java.lang.Thread.run(Thread.java:761)  
                            at com.google.android.apps.gsa.shared.util.concurrent.a.ad$1.run(SourceFile:85)  
08-01 19:54:43.591 2220-4313/com.google.android.googlequicksearchbox:search I/AudioController: internalShutdown 
08-01 19:54:43.601 2220-2220/com.google.android.googlequicksearchbox:search I/MicroDetector: Keeping mic open: false 
08-01 19:54:43.601 2220-2220/com.google.android.googlequicksearchbox:search I/MicroDetectionWorker: #onError(false) 
08-01 19:54:43.603 2220-4312/com.google.android.googlequicksearchbox:search I/DeviceStateChecker: DeviceStateChecker cancelled 
08-01 19:54:43.625 2220-2234/com.google.android.googlequicksearchbox:search I/art: Background sticky concurrent mark sweep GC freed 8140(454KB) AllocSpace objects, 7(2MB) LOS objects, 15% free, 14MB/17MB, paused 7.682ms total 89.059ms 
08-01 19:54:45.634 1900-2821/com.android.phone I/OmtpVvmCarrierCfgHlpr: OmtpEvent:CONFIG_STATUS_SMS_TIME_OUT 
08-01 19:54:45.641 1900-1900/com.android.phone I/RetryPolicy: discarding deferred status: configuration_state=4 
08-01 19:54:45.655 1900-1900/com.android.phone D/VvmTaskScheduler: No more tasks, stopping service if no task are added in 5000 millis 
08-01 19:54:45.661 1900-1900/com.android.phone D/VvmTaskScheduler: create task:com.android.phone.vvm.omtp.ActivationTask 
08-01 19:54:45.662 1900-1900/com.android.phone D/RetryPolicy: retry #2 for [email protected] queued, executing in 5000 
08-01 19:54:45.669 1900-1900/com.android.phone D/VvmTaskScheduler: minimal wait time:4995 
08-01 19:54:45.671 1900-1900/com.android.phone D/VvmTaskScheduler: minimal wait time:4993 
+0

Wenn Sie Crash Log vielleicht senden können wir Ihnen helfen –

+0

Das wäre ausgezeichnet. Leider bin ich relativ neu in Android Studio, und ich bin mir nicht sicher, wie ich die Absturzprotokolle finden kann. Ich habe es mehrere Male gegoogelt, aber ich bin auch nicht mit Android-Geräten im Allgemeinen vertraut, so dass ich immer noch ziemlich verwirrt bin. Wo finde ich das Unfallprotokoll? –

+0

Unten in der IDE gibt es eine Registerkarte namens "Android Monitor". Führen Sie Ihre App aus, das Crash-Protokoll ist dort verfügbar. –

Antwort

0

OOPS ... Ich habe vergessen, eine Aktivität zu dem Manifest File- ich jedem hinzufügen Hilfe zu schätzen weiß, und ich hoffe, dass dies auch nicht nehmen Zeit viel von jedermann!

Verwandte Themen