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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:50:48+00:00 2026-05-14T23:50:48+00:00

The title explains all… I have this snippet of code in my application: String

  • 0

The title explains all… I have this snippet of code in my application:

String url = createTelUrl("3112007315");
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(url));
context.startActivity(intent);

It does make a call, but once the call ends, my application crashes. I’d like to return to my application once the call has finished, but I read this post and it seems not to be possible. So… is there anyway to at least pause my application and resume it once the call has finished?

EDIT:

Thanks for the two answers I received, I feel I’m really close to my goal… I had already done some of the things you guys suggested. But, maybe I didn’t explain some details of the application… I’m developing Who Wants To Be A Millonarie game, so I need to implement calls (I don’t know how it’s called in USA or other countrys, but here we call it “call to a friend”).

Anyway… I’ve done too many changes to this app and now it’s not crashing. But, the Canvas where I draw the UI is not been showed once the called has ended.

I have a SurfaceView that holds the UI. For that SurfaceView I created a thread that is meant to refresh the UI… this is basically what the thread does:

@Override
public void run() {
    Canvas c;
    while (_run) {
        c = null;
        try {
            c = _surfaceHolder.lockCanvas(null);
            // Check if should wait
            synchronized (_surfaceHolder) {
                _panel.onDraw(c);
            }
        } finally {
            // do this in a finally so that if an exception is thrown
            // during the above, we don't leave the Surface in an
            // inconsistent state
            if (c != null) {
                _surfaceHolder.unlockCanvasAndPost(c);
            }
        }
    }
}

But, once the call has ended I get a black screen. The surface is there (I know it because it still can receive some touch events), but it’s not showing anything. Another thing to take in account is how I’m starting the Thread from the SurfaceView class:

public void surfaceCreated(SurfaceHolder holder) {
    hilo.setRunning(true);
    try{
        hilo.start();
    }catch(IllegalThreadStateException ite){
        Log.e("wwtbam", "god dammed");
    }
}

This worked nice before I start implementing phone-calls. The problem here is that once the call has ended and it executes again the start method which throws a IllegalThreadStateException because the thread has already been started. I’ve tried using some ‘technics’ to pause the UI thread while calling but I haven’t been able to solve this problem. I tried doing something like:

// this in the UI thread class
if(haveToWait)
    wait();
....
// this in the surface view class
if(callEnded)
    hilo.notify();

But that didn’t work. I also have tried some other ‘tricks’ like using sleep(50); instead of wait(); but it does not work either.

With all that information I provided… what could you suggest to me?

  • 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-05-14T23:50:48+00:00Added an answer on May 14, 2026 at 11:50 pm

    The problem here is the place you’re using to start the thread. Once you start a new call, your main activity will be paused and the surfaceview will be destroyed. Though, the thread will keep running. So, once your app takes the control back, the surface is created again and the start method will be invoked. That causes a IllegalThreadStateException.

    The way to go here is to manipulate the thread out of the SurfaceView class. That will give you the control of the thread from the main activity, and you will be able to decide when to start or pause your thread.

    Take a look of this example: http://code.google.com/p/apps-for-android/source/browse/trunk/SpriteMethodTest/src/com/android/spritemethodtest/

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

Sidebar

Related Questions

The title sort of explains itself. I am making some 'genrative' artwork in flash.
Title might be a bit confusing, so let me explain. I have a website
Title is the entire question. Can someone give me a reason why this happens?
Title pretty much sums it up. The external style sheet has the following code:
The title may not really explain what I'm really trying to get at, couldn't
I know the question title isn't the best. Let me explain. I do a
Title says what i'm trying to do. I can successfully generate an assembly if
Title says it mostly. I want to add a simple extension method to the
Title field is sealed. Any attempts to update the default value resets the value
Title: Eclipse plug-in development Unable to instantiate class due to java.lang.NoClassDefFoundError: Trying to build

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.