Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9042461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:29:52+00:00 2026-06-16T10:29:52+00:00

where to start.. I’m new to android and trying to create a small app

  • 0

where to start..
I’m new to android and trying to create a small app for android that would show time table (5 days and 8 hours), those’d be displayed as a table of 40 squares. User can add an event by choosing Day(from spinner), Time(spinner), add a note (max 15 characters) and choose a background color. All that has to be added to a string array and send to main activity. From there by getting day and time slot values from that string array appropriate square will be updated with text and background color from the same string array. I’ve been trying to solve this for about four days now, but I just can’t get my head round this… Here’s some code:
Main Activity:

package com.tt;

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

public class MainActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button settings = (Button)findViewById(R.id.settings);

        Intent a = getIntent();
        String[] add = a.getStringArrayExtra("strings");

        setContentView(R.layout.activity_main);
        TextView detail = (TextView)findViewById(R.id.m1);
        //detail.setText(notes);

        settings.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent i = new Intent(v.getContext(),Settings.class);
                startActivityForResult(i,0);
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}   

Add event:

package com.tt;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import android.app.Activity;
import android.content.Intent;

public class Add extends Activity implements OnClickListener, OnCheckedChangeListener {
    String[] DOW;
    String[] time;
    String  clr;
    EditText nts;
    boolean click = true;
    Button save;
    RadioGroup days;
    RadioGroup times;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.add);
        initialize();

        DOW = getResources().getStringArray(R.array.DOW);
        Spinner s1 =(Spinner)findViewById(R.id.spinner1);
        ArrayAdapter<String>adapter = new      ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item,DOW);
        s1.setAdapter(adapter);
        s1.setOnItemSelectedListener(new OnItemSelectedListener() {
            public void onItemSelected(AdapterView<?>arg0,View arg1, int arg2, long arg3) {
                int index = arg0.getSelectedItemPosition();
                Toast.makeText(getBaseContext(), "Chosen Day of the Week is     "+ DOW[index], Toast.LENGTH_SHORT).show();
            }
            @Override
            public void onNothingSelected(AdapterView<?>arg0){
                // nothing
            }
        });
        time = getResources().getStringArray(R.array.time);
        Spinner s2 = (Spinner)findViewById(R.id.spinner2);
        ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item,time);
        s2.setAdapter(adapter2);
        s2.setOnItemSelectedListener(new OnItemSelectedListener() {
            public void onItemSelected(AdapterView<?>arg0,View arg1, int arg2, long arg3) {
                int index = arg0.getSelectedItemPosition();
                Toast.makeText(getBaseContext(), "Time is set to "+ time[index], Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onNothingSelected(AdapterView<?> arg0) {
                // nothing
            }
        });
    }
    private void initialize() {
        save = (Button)findViewById(R.id.save);
        save.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                String notes = nts.getText().toString();
                String day = DOW.toString();
                String tim = time.toString();
                //String color = clr.

                Bundle b = new Bundle();
                /*bag.putString("key1", day);
                //bag.putString("key2",tim);
                //bag.putString("key3", notes);
                //bag.putString("key4", color);*/

                /*String[] added = new String[4];
                added[0]=day;
                added[1]=tim;
                added[2]=color;
                added[3]=notes;*/

                //b.putStringArray("key",added);
                String[] added = new String[] {day, tim, notes};
                //b.putStringArray("key", new String[]{day, tim, notes});
                Intent a = new Intent(Add.this, MainActivity.class);
                a.putExtra("strings",added);
                startActivity(a);
            }
        });
        nts = (EditText) findViewById(R.id.notes);
        //days.setOnCheckedChangeListener((OnCheckedChangeListener) this);
        //times.setOnCheckedChangeListener((OnCheckedChangeListener) this);
    }

    @Override
    public void onClick(View arg0) {
        // nothing
    }

    @Override
    public void onCheckedChanged(RadioGroup arg0, int arg1) {
        switch(arg1) {
        case R.id.blue:
            clr = "blue";
            break;
        case R.id.green:
            clr = "green";
            break;
        case R.id.yellow:
            clr = "yellow";
            break;
        case R.id.red:
            clr = "red";
            break;
        }
    }
}

UPDATE

Right… I’ve cut down string array to just one string… Here’s the code that suppose to send data:

    private void initialize() 
{
    save = (Button)findViewById(R.id.save);
    nts = (EditText) findViewById(R.id.notes);
}   
    public void onClick(View arg0) 
        {
            String notes = nts.getText().toString();
            //String day = DOW.toString();
            //String tim = time.toString();

            Bundle b = new Bundle();
            b.putString("AddedNote", notes);
            Intent a = new Intent(Add.this, MainActivity.class);
            a.putExtras(b);
            startActivity(a);
            /*String[] added = new String[] {notes};
            a.putExtra("strings",added);
            */
        };

And the “receiver”:

    public class MainActivity extends Activity
{
String gotNotes;
TextView notes;
   @Override
    public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initialize();
    Button settings = (Button)findViewById(R.id.settings);
    Bundle gotPackage = getIntent().getExtras();
    gotNotes = gotPackage.getString("AddedNote");
    if (gotNotes != "")
    {
    notes.setText(gotNotes);
    }
    else{}


    settings.setOnClickListener(new OnClickListener()
    {



          public void onClick(View v)
         {
              Intent i = new Intent(v.getContext(),Settings.class);
              startActivityForResult(i,0);
         }

    });

   }

    private void initialize() 
   {
    // TODO Auto-generated method stub
    notes = (TextView)findViewById(R.id.m1);
}

@Override
    public boolean onCreateOptionsMenu(Menu menu) 
   {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;

    }

  }

The result I’m getting is caused by java.lang.nullpointerexception at line :

   gotNotes = gotPackage.getString("AddedNote");

of the “receiver” activity..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T10:29:54+00:00Added an answer on June 16, 2026 at 10:29 am

    It depend on your activity android:launchMode, I suspect you have it singleTask or similar. In this case you should override onNewIntent where you should receive the intent with your strings array.

    Alternative solution, is to store data in a shared preference, you can serialize it as JSON object if needed.

    protected void onNewIntent(Intent intent) {
       String[] add = a.getStringArrayExtra("strings");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For start I would like to say that I am newbie. I am trying
Early start to the new year on SO for me :) I'm trying to
foreman start runs an app that i can visit on localhost How do I
Start of that I'm not that good with VBS but trying to learn. Right
I start studing iOS last week and before I go any further I would
Start with an array of integers so that the sum of the values is
To start, I'm using Rails v3.2.9 with Squeel 1.0.13 and here's what I'm trying
DateTime start = new DateTime().withYear(1884); System.out.println(start); System.out.println(start.minusYears(1)); Output 1884-01-11T08:26:10.234-08:00 1883-01-11T08:26:10.234-07:52:58 Edit 1: I was
To start off, i'm very new to networking with sockects and TCP/IP packets, i
I start with a new Delphi VCL application, add Menus to the uses clause,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.