Android program freezes before calling onCreate (newbie)

I needed a sample code to test the AudioRecord class, and I came across this site

REFERENCE TO SOURCE CODE
However, the program does not start and freezes after some time. When the program starts, it gives a blank screen and does nothing, and after a while a window appears informing that the program is not responding and if I want to close it.
So I added Toast.makeText(getApplicationContext(), "HERE", Toast.LENGTH_SHORT).show(); as the first line of onCreate() in MainActivity , but even this toast does not appear on the screen. Where are the possible places where the program may hang before you even call onCreate ()? How can I find this line of code? I tested it on an emulator.

0
source share
1 answer

I don’t know if its the exact reason, but in the XML layout file it refers to @+id/textView1 , but there is no TextView in the XML file. This may mean the TextView , which the SDK creates by default to show the label "Hello World", but has been removed from the example.
In fact, looking at the code in the layout more, the line android:layout_alignLeft="@+id/textView1" is wrong, since it has @+id/ , which means that it is trying to assign a new id/ to android:layout_alignLeft instead of matching value "@id/textView1" ,

+1
source

Source: https://habr.com/ru/post/1496713/


All Articles