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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:16:44+00:00 2026-05-28T01:16:44+00:00

So in my Android app, I’ve been testing how to detect an incoming and

  • 0

So in my Android app, I’ve been testing how to detect an incoming and outgoing call. I got it to work by building a class that extends a BroadcastReceiver, but in that class if I call another class it crashes. For example MyClass mc = new MyClass(); mc.functionname();

My actual app is running a looping sound clip. I want to pause that sound clip when an incoming or outgoing call is made. The soundclip is played in a class that extends Activity. How do I do this?

This is what I have for the BroadcastReceiver class and my manifest.

package com.anthony.phone;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;

public class inComingReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
        Bundle bundle = intent.getExtras();

        if(null == bundle)
                return;

        Log.i("MYTAG",bundle.toString());

        String state = bundle.getString(TelephonyManager.EXTRA_STATE);

        Log.i("MYTAG","State: "+ state);

        if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING))
        {
                String phonenumber = bundle.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);

                Log.i("MYTAG",":) Incomng Number: " + phonenumber);

                String info = "Detect Calls sample application\nIncoming number: " + phonenumber;

                Toast.makeText(context, info, Toast.LENGTH_LONG).show();

    }

}
}

and my manifest

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

    <uses-sdk android:minSdkVersion="10" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>

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

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <receiver android:name="com.anthony.phone.inComingReceiver">
            <intent-filter>
                <action android:name="android.intent.action.PHONE_STATE"/>
            </intent-filter>
        </receiver>


    </application>

</manifest>
  • 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-28T01:16:45+00:00Added an answer on May 28, 2026 at 1:16 am

    i had also this kind of problem. i solved by calling activity from broadcast receiver And writing my class code in particular Activity. As mentioned below

                Intent i = new Intent(context,newActivity.class);  
                i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  
                context.startActivity(i);  
    

    i hope it will help you to solve your query.
    ask me if you further have any doubt.

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

Sidebar

Related Questions

I'm writing an Android app for work that shows the status of our phone
I'm building an Android app and I want to copy the text value of
I've got an Android app which has a periodic background Service. I want this
I created a native Android app that basically hosts a webView control. That webView
i've developed an android app that's fetches an xml file and displays this data
My android-app gets List in the one activity, but activity,that contains the LisView for
My android app will work for both normal and hdpi device. I don't want
My android app works on landscape mode. I have a listview that contains some
My Android app is getting called by an intent that is passing information (pendingintent
In my android app I call the voice recognition in my onCreate method of

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.