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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:05:43+00:00 2026-06-06T13:05:43+00:00

I have an android app that plays audio from the application class. I have

  • 0

I have an android app that plays audio from the application class. I have a PhoneStateListener in my application class that pauses the audio when there is a phone call.

I want to start a particular activity when the call ends, but I am unable to. here is my code:

public void getPhoneState(){

TelephonyManager mgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
PhoneStateListener phoneStateListener = new PhoneStateListener() {
    @Override
    public void onCallStateChanged(int state, String incomingNumber) {

        if (state == TelephonyManager.CALL_STATE_RINGING) {
            if(audio.isPlaying())
               audioPlayer.pause();

        } 
            else if(state == TelephonyManager.CALL_STATE_IDLE) {

                audio.start();
                Intent missintent= new Intent(context,AudioActivity.class);
                missintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(missintent);


        } 
            else if(state == TelephonyManager.CALL_STATE_OFFHOOK) {

            if(audio.isPlaying())
            audioPlayer.pause();

        }
        super.onCallStateChanged(state, incomingNumber);


    }
};

if(mgr != null) {
    mgr.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
}
}

public boolean handleAudio(String source, int id) {

phoneState();
//Code for Playing Audio
.....
.....
}

I would appreciate it if someone could show me how to start the activity in the correct manner.

Thanks!

  • 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-06T13:05:45+00:00Added an answer on June 6, 2026 at 1:05 pm

    Ok so I know you found another solution already, but I was cracking around at it and found something that worked for me. Instead of calling an intent I used pendingIntent, an intent filter, and pending post. Here is a code snippit for anyone else out there having this issue.

    Context context = MyApplication.this.getApplicationContext();
    Intent errorActivity = new Intent("com.error.activity");//this has to match your intent filter
    errorActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 22, errorActivity, 0);
    try {
        pendingIntent.send();
        } 
    catch (CanceledException e) {
            // TODO Auto-generated catch block
        e.printStackTrace();
        }
    

    Then in your manifest just make sure you set the intent filter for the catching activity

    <activity
        android:name="UncaughtErrorDialogActivity"
        android:theme="@android:style/Theme.Dialog" >
        <intent-filter>
            <action android:name="com.error.activity" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an MP3 audio file that I want to play from my Android
I have a dialog in an Android app that I don't want the user
I have an app that I want to develop for Android 2.1, 2.2, 2.3.3,
I have a class that extends android.app.Dialog, the layout is done in an xml
I have a problem regarding Android App. I have created an application that download
I have an upload phone app that uploads either images or audio recordings. The
I have an android app that records audio and does other stuff, and I
Hello i'm a new coder to android. I have a program that Plays Pauses
I have an Android app that I had working a few months ago which
I have an Android app that begins by displaying a dialog. When I set

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.