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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:43:16+00:00 2026-05-21T14:43:16+00:00

I just want to know how to launch an Activity in a try/catch bloc,

  • 0

I just want to know how to launch an Activity in a try/catch bloc, i made this

    public void onReceive(Context context, Intent intent) {
            SipAudioCall incomingCall = null;
            try {
                Intent monIntent = new Intent(this,dialog.class);
                startActivity(monIntent);
                SipAudioCall.Listener listener = new SipAudioCall.Listener() {
@Override
                public void onRinging(SipAudioCall call, SipProfile caller) {

But i have errors:

constructor Intent(IncomingCallReceiver, Class<dialog>) is not defined
Method startActivity(Intent) is undefined for the type IncomingCallReceiver

I want to show an alertdialog when having a call.
How can i solve this problem?

Thank you very much.
Whole class:

public class IncomingCallReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        SipAudioCall incomingCall = null;
        try {

            SipAudioCall.Listener listener = new SipAudioCall.Listener() {
                @Override
                public void onRinging(SipAudioCall call, SipProfile caller) {
                    try {
                        call.answerCall(30);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            };

            SIPCommunicator wtActivity = (SIPCommunicator) context;

            incomingCall = wtActivity.manager.takeAudioCall(intent, listener);
            incomingCall.answerCall(30);
            incomingCall.startAudio();
            incomingCall.setSpeakerMode(true);
            if(incomingCall.isMuted()) {
                incomingCall.toggleMute();
            }

            wtActivity.call = incomingCall;

            wtActivity.updateStatus(incomingCall);

        } catch (Exception e) {
            if (incomingCall != null) {
                incomingCall.close();
            }
        }
    }

}
  • 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-21T14:43:16+00:00Added an answer on May 21, 2026 at 2:43 pm

    The problem you are facing is not the try catch block, it’s the fact that you are starting activity in a listener implementation. Substitute

    Intent monIntent = new Intent(this,dialog.class);
    

    with

    Intent monIntent = new Intent(<Name of this class>.this,dialog.class);
    

    and

     startActivity(monIntent);
    

    with

    <Name of this class>.this.startActivity(monIntent);
    

    By <Name of this class> I mean the head class where you are writing your code.

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

Sidebar

Related Questions

Just want to know if publishing an application on Google play is allowed using
Just want to know how to read an attribute of a parent node from
I just want to know why both the paint and draw methods are used
i just want to know, how to write Code behind(Hyperlink1_Click()), for the hyper link
I just want to know what is the actual difference between private and protected
I just want to know how to access an array in SMARTY that have
I just want to know how to code a animation like the one on
I just want to know if it is possible for an iPad and iPhone
I just want to know is there any tool works with silverlight3 for UI
I just want to know if is possible to calculate the diference between two

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.