this app has a textView for input and a button which invoke Finder function. The finder will find the input text in the array of strings and then display them in a listView. Following is the code for this scenario which is syntactically correct but at runtime, when I press the button the app crashes. The logcat result is also quoted here...
MainActivity.java
package com.neatsoft.hamqafia;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
EditText textBar;
Button findBtn;
ListView listView;
BaseAdapter adapter;
ArrayList<String> searchList;
String words[] = {"Dust", "Duff", "Great", "Man", "Grade", "Mole", "Tax"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Init();
}
private void Init(){
textBar = (EditText) findViewById(R.id.editText);
findBtn = (Button) findViewById(R.id.button);
listView = (ListView) findViewById(R.id.listView);
}
public void Finder(View view){
String toFind = textBar.getText().toString();
if(searchList == null) {
searchList = new ArrayList<String>();
}
searchList.clear();
if(toFind != null || !toFind.trim().equals("")) {
for(String str : words) {
if(str.toLowerCase().contains(toFind.toLowerCase()))
searchList.add(str);
}
}
notifyDataToListView();
}
private void notifyDataToListView() {
if(adapter == null) {
adapter = new BaseAdapter() {
@Override
public int getCount() {
return searchList == null ? 0 : searchList.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null) {
convertView = new TextView(getApplicationContext());
}
((TextView) convertView).setText(searchList.get(position));
return null;
}
};
listView.setAdapter(adapter);
}else {
adapter.notifyDataSetChanged();
}
}
}
LogCat:
2018-11-02 16:57:45.685 1873-2026/system_process D/WifiNative-HAL: Failing getSupportedFeatureset because HAL isn't started
2018-11-02 16:57:45.685 1873-1906/system_process E/BluetoothAdapter: Bluetooth binder is null
2018-11-02 16:57:45.686 1873-1906/system_process E/BatteryStatsService: no controller energy info supplied
2018-11-02 16:57:45.691 1873-1906/system_process E/KernelCpuSpeedReader: Failed to read cpu-freq: /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state (No such file or directory)
2018-11-02 16:57:45.692 1873-1906/system_process E/KernelUidCpuTimeReader: Failed to read uid_cputime: /proc/uid_cputime/show_uid_stat (No such file or directory)
2018-11-02 16:57:45.692 1873-1906/system_process E/BatteryStatsService: modem info is invalid: ModemActivityInfo{ mTimestamp=0 mSleepTimeMs=0 mIdleTimeMs=0 mTxTimeMs[]=[0, 0, 0, 0, 0] mRxTimeMs=0 mEnergyUsed=0}
2018-11-02 16:57:51.129 1873-1915/system_process W/ProcessCpuTracker: Skipping unknown process pid 10546
2018-11-02 16:58:24.679 1873-1883/system_process I/art: Background partial concurrent mark sweep GC freed 25111(1409KB) AllocSpace objects, 4(148KB) LOS objects, 25% free, 11MB/15MB, paused 10.534ms total 71.375ms
2018-11-02 16:58:30.130 1456-1488/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 3409397 , only wrote 3409200
2018-11-02 16:58:30.132 10445-10445/com.neatsoft.hamqafia D/AndroidRuntime: Shutting down VM
2018-11-02 16:58:30.133 10445-10445/com.neatsoft.hamqafia E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.neatsoft.hamqafia, PID: 10445
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getImportantForAccessibility()' on a null object reference
at android.widget.AbsListView.obtainView(AbsListView.java:2380)
at android.widget.ListView.makeAndAddView(ListView.java:1970)
at android.widget.ListView.fillDown(ListView.java:704)
at android.widget.ListView.fillFromTop(ListView.java:765)
at android.widget.ListView.layoutChildren(ListView.java:1744)
at android.widget.AbsListView.onLayout(AbsListView.java:2162)
at android.view.View.layout(View.java:17637)
at android.view.ViewGroup.layout(ViewGroup.java:5575)
at android.support.constraint.ConstraintLayout.onLayout(ConstraintLayout.java:1915)
at android.view.View.layout(View.java:17637)
at android.view.ViewGroup.layout(ViewGroup.java:5575)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:17637)
at android.view.ViewGroup.layout(ViewGroup.java:5575)
at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:443)
at android.view.View.layout(View.java:17637)
at android.view.ViewGroup.layout(ViewGroup.java:5575)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:17637)
at android.view.ViewGroup.layout(ViewGroup.java:5575)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:17637)
at android.view.ViewGroup.layout(ViewGroup.java:5575)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:726)
at android.view.View.layout(View.java:17637)
at android.view.ViewGroup.layout(ViewGroup.java:5575)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2346)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2068)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6337)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
at android.view.Choreographer.doCallbacks(Choreographer.java:686)
at android.view.Choreographer.doFrame(Choreographer.java:621)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
2018-11-02 16:58:30.134 1873-1888/system_process W/ActivityManager: Force finishing activity com.neatsoft.hamqafia/.MainActivity
2018-11-02 16:58:30.169 1456-1488/? W/audio_hw_generic: Hardware backing HAL too slow, could only write 0 of 720 frames
2018-11-02 16:58:30.200 1456-1489/? D/AudioFlinger: mixer(0xb3003280) throttle end: throttle time(12)
2018-11-02 16:58:30.304 1873-3632/system_process I/OpenGLRenderer: Initialized EGL, version 1.4
2018-11-02 16:58:30.304 1873-3632/system_process D/OpenGLRenderer: Swap behavior 1
2018-11-02 16:58:30.317 1873-3632/system_process D/EGL_emulation: eglCreateContext: 0xb1106920: maj 3 min 0 rcv 3
2018-11-02 16:58:30.327 1873-3632/system_process D/EGL_emulation: eglMakeCurrent: 0xb1106920: ver 3 0 (tinfo 0x91f67120)
2018-11-02 16:58:30.343 1873-3632/system_process D/EGL_emulation: eglMakeCurrent: 0xb1106920: ver 3 0 (tinfo 0x91f67120)
2018-11-02 16:58:30.645 1873-1903/system_process W/ActivityManager: Activity pause timeout for ActivityRecord{c32e9f5 u0 com.neatsoft.hamqafia/.MainActivity t25 f}
2018-11-02 16:58:30.760 1456-1488/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 3439461 , only wrote 3439440
2018-11-02 16:58:30.760 1456-1488/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 3439446 , only wrote 3439440
2018-11-02 16:58:30.776 1456-1488/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 3440175 , only wrote 3440160
2018-11-02 16:58:30.935 2741-2857/com.google.android.googlequicksearchbox:search D/EGL_emulation: eglMakeCurrent: 0xb1105720: ver 3 0 (tinfo 0xb11036c0)
2018-11-02 16:58:30.990 1310-2139/? D/gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 2691072
2018-11-02 16:58:31.034 1456-1488/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 3452579 , only wrote 3451680
2018-11-02 16:58:31.035 1456-1488/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 3451690 , only wrote 3451680
2018-11-02 16:58:31.050 1456-1488/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 3452433 , only wrote 3452400
2018-11-02 16:58:31.197 1456-1488/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 3459436 , only wrote 3453840
2018-11-02 16:58:31.203 1310-1310/? E/EGL_emulation: tid 1310: eglCreateSyncKHR(1962): error 0x3004 (EGL_BAD_ATTRIBUTE)
2018-11-02 16:58:31.243 1873-1914/system_process I/Choreographer: Skipped 32 frames! The application may be doing too much work on its main thread.
2018-11-02 16:58:31.248 1873-2417/system_process W/art: Long monitor contention with owner ActivityManager (1903) at android.graphics.Bitmap com.android.server.wm.WindowManagerService.screenshotApplicationsInner(android.os.IBinder, int, int, int, boolean, float, android.graphics.Bitmap$Config, boolean)(WindowManagerService.java:6469) waiters=1 in int com.android.server.wm.WindowManagerService.relayoutWindow(com.android.server.wm.Session, android.view.IWindow, int, android.view.WindowManager$LayoutParams, int, int, int, int, android.graphics.Rect, android.graphics.Rect, android.graphics.Rect, android.graphics.Rect, android.graphics.Rect, android.graphics.Rect, android.graphics.Rect, android.content.res.Configuration, android.view.Surface) for 400ms
2018-11-02 16:58:31.273 1873-1903/system_process I/ActivityManager: Killing 10296:com.android.keychain/1000 (adj 906): empty for 1800s
2018-11-02 16:58:31.303 1873-2188/system_process D/ActivityManager: cleanUpApplicationRecord -- 10296
2018-11-02 16:58:31.351 2741-2741/com.google.android.googlequicksearchbox:search I/OptInState: There is a new client and it does not support opt-in. Dropping request.
2018-11-02 16:58:31.356 1873-1883/system_process I/art: Background partial concurrent mark sweep GC freed 4337(244KB) AllocSpace objects, 0(0B) LOS objects, 25% free, 11MB/15MB, paused 2.020ms total 120.957ms
2018-11-02 16:58:31.369 2741-2741/com.google.android.googlequicksearchbox:search I/MicroDetectionWorker: Micro detection mode: [mDetectionMode: [1]].
2018-11-02 16:58:31.369 2741-2741/com.google.android.googlequicksearchbox:search I/AudioController: Using mInputStreamFactoryBuilder
2018-11-02 16:58:31.397 2064-2064/com.android.systemui W/asset: Asset path /data/app/com.neatsoft.hamqafia-2/base.apk is neither a directory nor file (type=1).
2018-11-02 16:58:31.397 2064-2064/com.android.systemui E/ResourcesManager: failed to add asset path /data/app/com.neatsoft.hamqafia-2/base.apk
2018-11-02 16:58:31.397 2064-2064/com.android.systemui W/PackageManager: Failure retrieving resources for com.neatsoft.hamqafia
2018-11-02 16:58:31.397 2064-2064/com.android.systemui W/asset: Asset path /data/app/com.neatsoft.hamqafia-2/base.apk is neither a directory nor file (type=1).
2018-11-02 16:58:31.397 2064-2064/com.android.systemui E/ResourcesManager: failed to add asset path /data/app/com.neatsoft.hamqafia-2/base.apk
2018-11-02 16:58:31.397 2064-2064/com.android.systemui W/PackageManager: Failure retrieving resources for com.neatsoft.hamqafia
2018-11-02 16:58:31.397 2064-2064/com.android.systemui W/asset: Asset path /data/app/com.neatsoft.hamqafia-2/base.apk is neither a directory nor file (type=1).
2018-11-02 16:58:31.397 2064-2064/com.android.systemui E/ResourcesManager: failed to add asset path /data/app/com.neatsoft.hamqafia-2/base.apk
2018-11-02 16:58:31.397 2064-2064/com.android.systemui W/PackageManager: Failure retrieving resources for com.neatsoft.hamqafia
2018-11-02 16:58:31.412 2064-2064/com.android.systemui W/asset: Asset path /data/app/com.neatsoft.hamqafia-2/base.apk is neither a directory nor file (type=1).
2018-11-02 16:58:31.412 2064-2064/com.android.systemui E/ResourcesManager: failed to add asset path /data/app/com.neatsoft.hamqafia-2/base.apk
2018-11-02 16:58:31.412 2064-2064/com.android.systemui W/PackageManager: Failure retrieving resources for com.neatsoft.hamqafia
2018-11-02 16:58:31.431 2741-10560/com.google.android.googlequicksearchbox:search I/MicroRecognitionRunner: Starting detection.
2018-11-02 16:58:31.450 2741-10555/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_starting com.google.android.apps.gsa.staticplugins.z.c@6737a0
2018-11-02 16:58:31.452 2741-2752/com.google.android.googlequicksearchbox:search I/art: WaitForGcToComplete blocked for 20.121ms for cause Background
2018-11-02 16:58:31.461 1456-10565/? I/AudioFlinger: AudioFlinger's thread 0xace03980 ready to run
2018-11-02 16:58:31.462 2741-10561/com.google.android.googlequicksearchbox:search W/LocationOracle: No location history returned by ContextManager
2018-11-02 16:58:31.469 1456-2041/? E/AudioFlinger: not enough memory for AudioTrack size=131296
2018-11-02 16:58:31.470 1456-2041/? D/MemoryDealer: AudioTrack (0xb359cdc0, size=4194304)
0: 0xb359cdd0 | 0x00000000 | 0x000200E0 | A
1: 0xb359cdf0 | 0x000200E0 | 0x000200E0 | A
2: 0xb2c8c150 | 0x000401C0 | 0x000200E0 | A
3: 0xb359cd80 | 0x000602A0 | 0x000200E0 | A
4: 0xb359cf70 | 0x00080380 | 0x000200E0 | A
5: 0xb25ff200 | 0x000A0460 | 0x000200E0 | A
6: 0xb25ff360 | 0x000C0540 | 0x000200E0 | A
7: 0xb25ff180 | 0x000E0620 | 0x000200E0 | A
8: 0xb25ff480 | 0x00100700 | 0x000200E0 | A
9: 0xb25ff6a0 | 0x001207E0 | 0x000200E0 | A
10: 0xb25ff880 | 0x001408C0 | 0x000200E0 | A
11: 0xb25ff9e0 | 0x001609A0 | 0x000200E0 | A
12: 0xb2c8c470 | 0x00180A80 | 0x000200E0 | A
13: 0xb25ffb80 | 0x001A0B60 | 0x000200E0 | A
14: 0xb25ffcb0 | 0x001C0C40 | 0x000200E0 | A
15: 0xb25ff5c0 | 0x001E0D20 | 0x000200E0 | A
16: 0xb0b7f030 | 0x00200E00 | 0x000200E0 | A
17: 0xb2c8c560 | 0x00220EE0 | 0x000200E0 | A
18: 0xb0b7f180 | 0x00240FC0 | 0x000200E0 | A
19: 0xb0b7f370 | 0x002610A0 | 0x000200E0 | A
2018-11-02 16:58:31.470 1456-2041/? E/AudioFlinger: createRecordTrack_l() initCheck failed -12; no control block?
2018-11-02 16:58:31.470 2741-10555/com.google.android.googlequicksearchbox:search E/AudioRecord: AudioFlinger could not create record track, status: -12
2018-11-02 16:58:31.476 2741-10555/com.google.android.googlequicksearchbox:search E/AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -12.
2018-11-02 16:58:31.476 2741-10555/com.google.android.googlequicksearchbox:search E/android.media.AudioRecord: Error code -20 when initializing native AudioRecord object.
2018-11-02 16:58:31.477 2741-10555/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_started com.google.android.apps.gsa.staticplugins.z.c@6737a0
2018-11-02 16:58:31.477 2741-10555/com.google.android.googlequicksearchbox:search E/ActivityThread: Failed to find provider info for com.google.android.apps.gsa.testing.ui.audio.recorded
2018-11-02 16:58:31.478 2741-2741/com.google.android.googlequicksearchbox:search I/MicroDetectionWorker: onReady
2018-11-02 16:58:31.481 2741-10560/com.google.android.googlequicksearchbox:search W/SpeechLevelGenerator: Really low audio levels detected. The audio input may have issues.
2018-11-02 16:58:31.497 2741-10560/com.google.android.googlequicksearchbox:search I/MicroRecognitionRunner: Detection finished
2018-11-02 16:58:31.497 2741-10560/com.google.android.googlequicksearchbox:search W/ErrorReporter: reportError [type: 211, code: 524300]: Error reading from input stream
2018-11-02 16:58:31.498 2741-10560/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)
2018-11-02 16:58:31.498 2741-10560/com.google.android.googlequicksearchbox:search I/AudioController: internalShutdown
2018-11-02 16:58:31.498 2741-10555/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_close com.google.android.apps.gsa.staticplugins.z.c@6737a0
2018-11-02 16:58:31.499 2741-2888/com.google.android.googlequicksearchbox:search I/MicroRecognitionRunner: Stopping hotword detection.
2018-11-02 16:58:31.501 2741-2741/com.google.android.googlequicksearchbox:search I/MicroDetector: Keeping mic open: false
2018-11-02 16:58:31.501 2741-2741/com.google.android.googlequicksearchbox:search I/MicroDetectionWorker: #onError(false)
2018-11-02 16:58:31.502 2741-10559/com.google.android.googlequicksearchbox:search I/DeviceStateChecker: DeviceStateChecker cancelled
2018-11-02 16:58:31.509 1873-2417/system_process I/GnssLocationProvider: WakeLock acquired by sendMessage(3, 0, com.android.server.location.GnssLocationProvider$GpsRequest@7700eef)
2018-11-02 16:58:31.513 1873-1902/system_process I/GnssLocationProvider: WakeLock released by handleMessage(3, 0, com.android.server.location.GnssLocationProvider$GpsRequest@7700eef)
2018-11-02 16:58:31.560 1456-1488/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 3471244 , only wrote 3471120
2018-11-02 16:58:31.560 1456-1488/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 3471125 , only wrote 3471120
2018-11-02 16:58:31.607 1456-1488/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 3473368 , only wrote 3473280
2018-11-02 16:58:31.662 1873-1904/system_process I/Choreographer: Skipped 78 frames! The application may be doing too much work on its main thread.
2018-11-02 16:58:31.721 10062-10083/com.google.android.apps.nexuslauncher D/EGL_emulation: eglMakeCurrent: 0x93d1c500: ver 3 0 (tinfo 0xa185d490)
2018-11-02 16:58:32.032 1873-2188/system_process I/ActivityManager: Killing 10264:com.android.gallery3d/u0a46 (adj 906): empty for 1800s
2018-11-02 16:58:32.090 1873-5581/system_process D/ActivityManager: cleanUpApplicationRecord -- 10264
2018-11-02 16:58:32.217 10062-10083/com.google.android.apps.nexuslauncher W/OpenGLRenderer: Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
2018-11-02 16:58:32.317 1456-1488/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 3507367 , only wrote 3507120
2018-11-02 16:58:32.318 1456-1488/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 3507172 , only wrote 3507120
2018-11-02 16:58:32.334 1456-1488/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 3507909 , only wrote 3507840
2018-11-02 16:58:32.555 1456-1488/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 3518433 , only wrote 3517920
2018-11-02 16:58:32.631 1456-1488/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 3521528 , only wrote 3521520
2018-11-02 16:58:32.744 1873-1903/system_process I/ActivityManager: Killing 10331:com.google.android.apps.docs/u0a41 (adj 906): empty for 1800s
2018-11-02 16:58:32.827 1873-2043/system_process D/ActivityManager: cleanUpApplicationRecord -- 10331
2018-11-02 16:58:32.872 1456-1488/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 3533110 , only wrote 3533040
2018-11-02 16:58:33.443 1456-1489/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 3586885 , only wrote 3560400
2018-11-02 16:58:36.505 2741-2741/com.google.android.googlequicksearchbox:search I/MicroDetectionWorker: Micro detection mode: [mDetectionMode: [1]].
2018-11-02 16:58:36.505 2741-2741/com.google.android.googlequicksearchbox:search I/AudioController: Using mInputStreamFactoryBuilder
2018-11-02 16:58:36.512 2741-10567/com.google.android.googlequicksearchbox:search I/MicroRecognitionRunner: Starting detection.
2018-11-02 16:58:36.512 2741-10555/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_starting com.google.android.apps.gsa.staticplugins.z.c@78de2ef
2018-11-02 16:58:36.515 1456-10570/? I/AudioFlinger: AudioFlinger's thread 0xace037c0 ready to run
2018-11-02 16:58:36.519 1456-1493/? E/AudioFlinger: not enough memory for AudioTrack size=131296
2018-11-02 16:58:36.519 1456-1493/? D/MemoryDealer: AudioTrack (0xb359cdc0, size=4194304)
0: 0xb359cdd0 | 0x00000000 | 0x000200E0 | A
1: 0xb359cdf0 | 0x000200E0 | 0x000200E0 | A
2: 0xb2c8c150 | 0x000401C0 | 0x000200E0 | A
3: 0xb359cd80 | 0x000602A0 | 0x000200E0 | A
4: 0xb359cf70 | 0x00080380 | 0x000200E0 | A
5: 0xb25ff200 | 0x000A0460 | 0x000200E0 | A
Your getView()
of Adapter is returning null
value.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null) {
convertView = new TextView(getApplicationContext());
}
((TextView) convertView).setText(searchList.get(position));
return null; // <<<<<< PROBLEM IS HERE
}
Which must return convertView as below
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null) {
convertView = new TextView(getApplicationContext());
}
((TextView) convertView).setText(searchList.get(position));
return convertView;
}
Even other methods getItem()
and getItemId()
are not correctly defined. I would suggest you to read about these methods and how you should override them.
Till then these methods would be like
@Override
public Object getItem(int position) {
if (searchList == null || searchList.isEmpty()) {
return null;
} else {
return searchList.get(position);
}
}
@Override
public long getItemId(int position) {
return position; // Better is to return id field of data if you have
}
And as you are new here I would like to add one more thing, there are identical problem with answers, like java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getImportantForAccessibility()' on a null object reference. So in future try to search first, learn from already answered questions.
User contributions licensed under CC BY-SA 3.0