Saturday 14 September 2019

android - When I run the program then I face runtime issue

public class MainActivity extends AppCompatActivity {

Spinner basic_command;

String basic_cmd_buff[]= null;

Button button;

ArrayAdapter adapter;


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

setContentView(R.layout.activity_main);

basic_command = (Spinner) findViewById(R.id.basic_command);


basic_cmd_buff = new String[]
{
"WOPEN","CSQ","CREG","CGREG?","IPCONNECT"
};


adapter = new ArrayAdapter<>(this,android.R.layout.simple_list_item_1,basic_cmd_buff);
basic_command.setAdapter(adapter);
}

public void back(View view)
{
finish();
}




}


And this is the error log:




02-02 13:57:26.562 27179-27179/com.example.sunbeam.test_application E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.sunbeam.test_application, PID: 27179
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sunbeam.test_application/com.example.sunbeam.test_application.MainActivity}: java.lang.NullPointerException

at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.example.sunbeam.test_application.MainActivity.onCreate(MainActivity.java:38)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
at android.app.ActivityThread.access$800(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 

at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5017) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...