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 8822409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:06:06+00:00 2026-06-14T06:06:06+00:00

Has anyone met this situation when creating a bar-chart in android I am trying

  • 0

Has anyone met this situation when creating a bar-chart in android

I am trying to create a bar-chart in android using Achartengine.But i am actually getting the input values ie. x and y axis values (for creating a bar-chart) from the web service by consuming it.

My logcat is showing like this. What does this meant?

LOGCAT

11-10 14:45:37.483: W/KeyCharacterMap(421): No keyboard for id 0
11-10 14:45:37.483: W/KeyCharacterMap(421): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
11-10 14:45:44.044: D/AndroidRuntime(421): Shutting down VM
11-10 14:45:44.044: W/dalvikvm(421): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
11-10 14:45:44.054: E/AndroidRuntime(421): FATAL EXCEPTION: main
11-10 14:45:44.054: E/AndroidRuntime(421): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.xmlparsing_test/com.example.xmlparsing_test.BarGraphActivity}: java.lang.NullPointerException
11-10 14:45:44.054: E/AndroidRuntime(421):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
11-10 14:45:44.054: E/AndroidRuntime(421):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-10 14:45:44.054: E/AndroidRuntime(421):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-10 14:45:44.054: E/AndroidRuntime(421):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-10 14:45:44.054: E/AndroidRuntime(421):  at android.os.Handler.dispatchMessage(Handler.java:99)
11-10 14:45:44.054: E/AndroidRuntime(421):  at android.os.Looper.loop(Looper.java:123)
11-10 14:45:44.054: E/AndroidRuntime(421):  at android.app.ActivityThread.main(ActivityThread.java:4627)
11-10 14:45:44.054: E/AndroidRuntime(421):  at java.lang.reflect.Method.invokeNative(Native Method)
11-10 14:45:44.054: E/AndroidRuntime(421):  at java.lang.reflect.Method.invoke(Method.java:521)
11-10 14:45:44.054: E/AndroidRuntime(421):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-10 14:45:44.054: E/AndroidRuntime(421):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-10 14:45:44.054: E/AndroidRuntime(421):  at dalvik.system.NativeStart.main(Native Method)
11-10 14:45:44.054: E/AndroidRuntime(421): Caused by: java.lang.NullPointerException
11-10 14:45:44.054: E/AndroidRuntime(421):  at com.example.xmlparsing_test.BarGraphActivity.buildBarDataset(BarGraphActivity.java:133)
11-10 14:45:44.054: E/AndroidRuntime(421):  at com.example.xmlparsing_test.BarGraphActivity.DrawGraph(BarGraphActivity.java:77)
11-10 14:45:44.054: E/AndroidRuntime(421):  at com.example.xmlparsing_test.BarGraphActivity.onCreate(BarGraphActivity.java:46)
11-10 14:45:44.054: E/AndroidRuntime(421):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-10 14:45:44.054: E/AndroidRuntime(421):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-10 14:45:44.054: E/AndroidRuntime(421):  ... 11 more
11-10 14:45:45.794: I/Process(421): Sending signal. PID: 421 SIG: 9

BarGraphActivity.java

public class BarGraphActivity extends Chart 
{

int[] order,freight,margin;

int[] x_axis   = order;
int[] y_axis   = freight;
int[] mpercent = margin;

public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main1);

    Bundle extras = getIntent().getExtras();
    if(extras != null)
    {   
        order   = extras.getIntArray("gotonextpage");
        freight = extras.getIntArray("gotonextpage");
        margin  = extras.getIntArray("gotonextpage");

    } else {}

    /*x_axis = new int[1];
    y_axis = new int[1];

    x_axis[0] = getIntent().getIntExtra("orderNo", 90);
    y_axis[0] = getIntent().getIntExtra("freightRate", 80);*/

    DrawGraph();
}

public void DrawGraph() 
{
    String[] titles = new String[] { " Barcharts", "" };
    List<int[]> values = new ArrayList<int[]>();

    values.add(order);
    values.add(freight);
    values.add(margin);

    int[] colors = new int[] { Color.WHITE, Color.BLACK };

    XYMultipleSeriesRenderer renderer = buildBarRenderer(colors);
    renderer.setOrientation(Orientation.HORIZONTAL);

    setChartSettings(renderer, "some texts", " ", " ", 0, order, 0, freight, Color.RED, Color.LTGRAY);

    renderer.setXLabels(1);
    renderer.addXTextLabel(2, "orderNo");
    renderer.addYTextLabel(2, "freight");
    renderer.setPanEnabled(true, false);

    int length = renderer.getSeriesRendererCount();

    for (int i = 0; i < length; i++) 
    {
        SimpleSeriesRenderer seriesRenderer = renderer.getSeriesRendererAt(i);
        seriesRenderer.setDisplayChartValues(true);
    }
    ChartFactory.getBarChartIntent(this, buildBarDataset(titles, values), renderer, Type.DEFAULT);
}

public XYMultipleSeriesRenderer buildBarRenderer(int[] colors) 
{

    // creates a SeriesRenderer and initializes it with useful default values as well as colors

    XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();

    renderer.setAxisTitleTextSize(15);
    renderer.setChartTitleTextSize(20);
    renderer.setLabelsTextSize(15);
    renderer.setLegendTextSize(15);

    int length = colors.length; 

    for (int i = 0; i < length; i++) 
    {
        SimpleSeriesRenderer r = new SimpleSeriesRenderer();
        r.setColor(colors[i]);
        renderer.addSeriesRenderer(r);
    }

    return renderer;
}

public void setChartSettings(XYMultipleSeriesRenderer renderer, String title, String xTitle, String yTitle,
int xMin, int[] order2, int yMin, int[] freight2, int axesColor, int labelsColor) 
{

// sets lots of default values for this renderer

    renderer.setChartTitle(title);
    renderer.setXTitle(xTitle);
    renderer.setYTitle(yTitle);
    renderer.setXAxisMin(xMin);
    renderer.setYAxisMin(yMin);
    renderer.setAxesColor(axesColor);
    renderer.setLabelsColor(labelsColor);
    renderer.setApplyBackgroundColor(true);
    renderer.setBackgroundColor(Color.BLACK);
}

public XYMultipleSeriesDataset buildBarDataset(String[] titles, List<int[]> values) 
{
    // adds the axis titles and values into the dataset

    XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();

    int length = titles.length;

    for (int i = 0; i < length; i++) 
    {
        CategorySeries series = new CategorySeries(titles[i]);
        int[] v = values.get(i);
        int seriesLength = v.length;

        for (int k = 0; k < seriesLength; k++) 
        {
            series.add(v[k]);
        }

        dataset.addSeries(series.toXYSeries());
    }
    return dataset;
    }
}

Chart.java

public class Chart extends Activity 
{
EditText edt1, edt2;
TextView txtv1;
Button btn;

String orderNo = "";
int freightRate = 0;
int marginPercent = 0;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    edt1 = (EditText) findViewById(R.id.editText1);
    edt2 = (EditText) findViewById(R.id.editText2);
    btn = (Button) findViewById(R.id.button1);

    btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            getTMSChart(edt1.getText().toString(), edt2.getText().toString());

            Intent intnt = new Intent(v.getContext(), BarGraphActivity.class);

            intnt.putExtra("orderNo", orderNo); 
            intnt.putExtra("freightRate", freightRate);
            intnt.putExtra("marginPercent", marginPercent);

            startActivity(intnt);
        }
    });
}

public void getTMSChart(String FromDate, String ToDate) 
{

    System.setProperty("http.keepAlive", "false");
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

    envelope.dotNet = true;

    String METHOD = "GetTMSChart";
    String NAMESPACE = "http://tempuri.org/";
    String SOAP_ACTION = "http://tempuri.org/GetTMSChart";
    String URL = "http://54.251.60.177/TMSOrdersService/TMSDetails.asmx";

    SoapObject request = new SoapObject(NAMESPACE, METHOD);
    request.addProperty("FromDate", FromDate.trim());
    request.addProperty("ToDate", ToDate.trim());

    envelope.setOutputSoapObject(request);
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try {

        androidHttpTransport.call(SOAP_ACTION, envelope);
        SoapObject result = (SoapObject) envelope.bodyIn;

        SoapObject root = (SoapObject) ((SoapObject) (result).getProperty(0)).getProperty("NewDataSet");

        int tablesCount = root.getPropertyCount();

        for (int i = 0; i < tablesCount; i++) 
        {
            SoapObject table = (SoapObject) root.getProperty(i);

            orderNo = table.getPropertyAsString("Order_No").replace("OR", "");
            freightRate = Integer.parseInt(table.getPropertyAsString("Freight_Rate"));
            marginPercent = Integer.parseInt(table.getPropertyAsString("Margin_Percent"));

        //  Toast.makeText(getApplicationContext(), "", Toast.LENGTH_LONG).show();

        for(int j = 0; j < tablesCount; j++)
        {
            int ord,fre,marg;

            Bundle extras = getIntent().getExtras();

            if(extras!=null )
            {
                ord  = extras.getInt("gotonextpage");
                fre  = extras.getInt("gotonextpage");
                marg = extras.getInt("gotonextpage");
                }

            else{}
            }   
        }
    }
catch (Exception e) 
{
    Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
    e.printStackTrace();
    }
}}
  • 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-14T06:06:07+00:00Added an answer on June 14, 2026 at 6:06 am

    You are not reading Extra of intent properly. This is just one problem. There are many other things wrong too.

    You put extras to intent with this code :

    intnt.putExtra("orderNo", orderNo); 
    intnt.putExtra("freightRate", freightRate);
    intnt.putExtra("marginPercent", marginPercent);
    

    And you get them with :

    order   = extras.getIntArray("gotonextpage");
    freight = extras.getIntArray("gotonextpage");
    margin  = extras.getIntArray("gotonextpage");
    

    The keys and types are all wrong.

    You are passing extra data to intent via these variables:

    String orderNo = "";
    int freightRate = 0;
    int marginPercent = 0;
    

    To store it in target activity you use

    int[] order,freight,margin;
    

    Why?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Has anyone met this error? Right now i am trying to do switch from
Has anyone met this problem ? I've checked the output of phpinfo() ,and see
Has anyone ever used the hidden class PackageParser in Android source code with java
Has anyone ever run into this issue before? Sometimes the string displays, sometimes half
Has anyone tried using the NHibernate Velocity L2 cache provider against the Azure AppFabric
Has anyone else come across this at all? I used to be able to
Has anyone had a go at creating a view that sorts a collection? The
Has anyone used tried the custom select boxes from link text I'm trying to
Has anyone got EclipseLink MOXy (I'm using eclipselink 2.1.0) to work with Java 5?
I've been trying to create a Metro based client for a WCF service, using

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.