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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:02:48+00:00 2026-06-09T05:02:48+00:00

I’m writing an Android app that connects to a Bluetooth device, reads in data,

  • 0

I’m writing an Android app that connects to a Bluetooth device, reads in data, and graphs it in the main Activity using AChartEngine (this entire part works).

I want to include a second Activity, which contains a WebView (powered by PhoneGap). When a button is pressed in the main Activity, the second Activity should open while the initial one continues to be alive in the background and the AChartEngine graph continues to be updated.

My current code approaches this problem using an AsyncTask, which works fine before the app starts accepting and graphing data over Bluetooth. After that happens, when I press the button to open the second Activity, the entire application crashes.

How do I show one Activity in the foreground while manipulating another Activity in the background? I’ve considered that the limit on the number of AsyncTasks open could be causing this issue, since I create a new AsyncTask for every data point I receive in order to add it to the graph asynchronously, but the number open at any time seems to be well under the limit.

Here are the relevant parts of my current code:

public class viewer extends Activity
{
    /* ... */

    public void handleButtonPress() {
        // called when our button is pressed
        new StartWebview(viewer.this).execute();
    }

    protected class StartWebview extends AsyncTask<Void, Void, Void> {
        public Activity activity;

        public StartWebview(Activity activity) {
            this.activity = activity;
        }

        @Override
        protected Void doInBackground(Void... values) {
            Intent i = new Intent(viewer.this, WebActivity.class);
            activity.startActivity(i);
            return null;
        }
    }

    protected class NewPoints extends AsyncTask<Double, Void, Void> { // called each time we receive a new data point

        @Override
        protected Void doInBackground(Double... values) {
            mCurrentSeries.add(values[0], values[1]); // x, y
            if (mChartView != null) {
                mChartView.repaint();
            }
            return null;
        }
    }
}
public class WebActivity extends DroidGap
{
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.loadUrl("file:///android_asset/www/index.html");
    }
}
  • 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-09T05:02:50+00:00Added an answer on June 9, 2026 at 5:02 am

    Once an activity is no longer shown, it entirely possible for Android to destroy it completely.

    You should be doing your data collection from a foreground service putting the data into a persistant data store like a contentprovider backed by sqlite database.

    Then use a loader to fetch the data and provide it to your charting tool. The content provider will be notified each time new data arrives in the database automatically.

    This might sound overkill, but you’d be loosing all your data and potentially crashing anyway even on a simple screen rotation.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into

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.