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

  • SEARCH
  • Home
  • 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 7999285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:27:45+00:00 2026-06-04T15:27:45+00:00

I’m new in Android and I have to plot a ECG WAVES on android

  • 0

I’m new in Android and I have to plot a ECG WAVES on android Tab or Phone and I have tried to use achartengine library to get my data on the lineGrap but I’m getting the NullPointerException.
Can u please help me!!!

Here is my GraphActivity.java

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

public class GraphActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button strt = (Button) findViewById(R.id.LineGraph);

        strt.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                lineGraph line = new lineGraph();
                Intent lineIntent = line.getIntent(getApplicationContext());
                startActivity(lineIntent);

            }
        });
    }

Here is my lineGraph.java

public class lineGraph {


    static BufferedReader reader ;
    static DataInputStream data_in;

    static int[] x = new int[6000]; // x values
    static int[] y1= new int[6000]; // y1 values
    static int[] y2= new int[6000]; // y2 values
    static int[] y3= new int[6000]; // y3 values
    static int[] y4= new int[6000]; // y4 values
    static int[] y5= new int[6000]; // y5 values
    static int[] y6= new int[6000]; // y6 values
    static int[] y7= new int[6000]; // y7 values
    static int[] y8= new int[6000]; // y8 values

    static int ch =0;

    public  Intent getIntent(Context context){

        try {
            data_in = new DataInputStream(
                        new BufferedInputStream(
                                new FileInputStream(new File("src/data.txt"))));
        } catch (FileNotFoundException e) {

            e.printStackTrace();
        }
        try {
             while(ch<6000){
                 Byte LSB = data_in.readByte();
                 Byte MSB = data_in.readByte();
                  int current= ((MSB<<8)| (LSB & 0xFF));
                y1[ch]=  current; 
                ch++;
                }
                while(ch>=6000 && ch<12000){
                    Byte LSB = data_in.readByte();
                    Byte MSB = data_in.readByte();
                   int current= ((MSB<<8)| (LSB & 0xFF));
                   y2[ch-6000]= current;
                   ch++;
                    }


         }
         catch(EOFException eof) {
             System.out.println ("End of File read");
//             break;
         } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
       try {
        data_in.close();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }  
//   }
        for(int i=0;i<6000;i++){
         x[i]=i;
        }

        TimeSeries series1 = new TimeSeries("line1");
        for(int i=0;i<x.length;i++){
            series1.add(x[i], y1[i]);
        }
        TimeSeries series2 = new TimeSeries("line2");
        for(int i=0;i<x.length;i++){
            series1.add(x[i], y2[i]);
        }
        TimeSeries series3 = new TimeSeries("line3");
        for(int i=0;i<x.length;i++){
            series1.add(x[i], y3[i]);
        }
        TimeSeries series4 = new TimeSeries("line4");
        for(int i=0;i<x.length;i++){
            series1.add(x[i], y4[i]);
        }
        XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
        dataset.addSeries(series1);
        dataset.addSeries(series2);
        dataset.addSeries(series3);
        dataset.addSeries(series4);

        XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
        XYSeriesRenderer renderer= new XYSeriesRenderer();
        renderer.setColor(Color.GREEN);
        renderer.setPointStyle(PointStyle.CIRCLE);
        renderer.setFillPoints(true);
        mRenderer.addSeriesRenderer(renderer);

        Intent intent = ChartFactory.getLineChartIntent(context, dataset, mRenderer, "Line Graph");
        return intent;

        }
    }

here is my Android Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.praktikum.graph"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="10" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".GraphActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="org.achartengine.GraphicalActivity"/>
    </application>

</manifest>

and my LogCat

    05-24 13:03:41.309: E/AndroidRuntime(21551): FATAL EXCEPTION: main
05-24 13:03:41.309: E/AndroidRuntime(21551): java.lang.NullPointerException
05-24 13:03:41.309: E/AndroidRuntime(21551):    at com.praktikum.graph.lineGraph.getIntent(lineGraph.java:58)
05-24 13:03:41.309: E/AndroidRuntime(21551):    at com.praktikum.graph.GraphActivity$1.onClick(GraphActivity.java:22)
05-24 13:03:41.309: E/AndroidRuntime(21551):    at android.view.View.performClick(View.java:3127)
05-24 13:03:41.309: E/AndroidRuntime(21551):    at android.view.View$PerformClick.run(View.java:12025)
05-24 13:03:41.309: E/AndroidRuntime(21551):    at android.os.Handler.handleCallback(Handler.java:587)
05-24 13:03:41.309: E/AndroidRuntime(21551):    at android.os.Handler.dispatchMessage(Handler.java:92)
05-24 13:03:41.309: E/AndroidRuntime(21551):    at android.os.Looper.loop(Looper.java:132)
05-24 13:03:41.309: E/AndroidRuntime(21551):    at android.app.ActivityThread.main(ActivityThread.java:4126)
05-24 13:03:41.309: E/AndroidRuntime(21551):    at java.lang.reflect.Method.invokeNative(Native Method)
05-24 13:03:41.309: E/AndroidRuntime(21551):    at java.lang.reflect.Method.invoke(Method.java:491)
05-24 13:03:41.309: E/AndroidRuntime(21551):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
05-24 13:03:41.309: E/AndroidRuntime(21551):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
05-24 13:03:41.309: E/AndroidRuntime(21551):    at dalvik.system.NativeStart.main(Native Method)
05-24 13:03:43.319: I/dalvikvm(21551): threadid=4: reacting to signal 3
05-24 13:03:43.319: I/dalvikvm(21551): Wrote stack traces to '/data/anr/traces.txt'

Thank you in advance for your Help

  • 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-04T15:27:46+00:00Added an answer on June 4, 2026 at 3:27 pm

    In android you need to put the such text file in asset or raw ….

    and read in such way

    http://www.javacodegeeks.com/2012/02/android-read-file-from-assets.html

     // To load text file
            InputStream input;
      try {
       input = assetManager.open("helloworld.txt");
    
              int size = input.available();
              byte[] buffer = new byte[size];
              input.read(buffer);
              input.close();
    
              // byte buffer into a string
              String text = new String(buffer);
    
              txtContent.setText(text);
      } catch (IOException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
      }
    

    and
    Reading a simple text file

    and

    http://android-er.blogspot.in/2010/07/display-text-file-in-resraw_01.html

    private String readTxt(){
    
         InputStream inputStream = getResources().openRawResource(R.raw.hello);
    
         ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    
         int i;
      try {
       i = inputStream.read();
       while (i != -1)
          {
           byteArrayOutputStream.write(i);
           i = inputStream.read();
          }
          inputStream.close();
      } catch (IOException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
      }
    
         return byteArrayOutputStream.toString();
        }
    

    and

    http://androidgps.blogspot.in/2008/10/dealing-with-large-resources.html

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.