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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:09:46+00:00 2026-06-16T17:09:46+00:00

Here is my code. I am not able to call my receiver class from

  • 0

Here is my code. I am not able to call my receiver class from main activity class. Please help.

public class RecorderActivity extends Activity {           

@Override       
public void onCreate(Bundle savedInstanceState) {           
    super.onCreate(savedInstanceState);           
    setContentView(R.layout.main);                      

    Intent i = new Intent(this, CallRecorder.class);
    startActivity(i);
    } 
}

   /////////////////////////////////////

 class CallRecorder extends BroadcastReceiver {

private static final String AUDIO_RECORDER_FOLDER = "AudioRecorder";       
private MediaRecorder recorder = null;
boolean recordstarted = false;
String phonenbr = null;
TelephonyManager telManager;

@Override
public void onReceive(Context context, Intent intent) {

    // TODO Auto-generated method stub
    if (intent.getAction().equalsIgnoreCase(Intent.ACTION_ANSWER)) 
    {
        try
        {
            phonenbr = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
            Log.v("GDHGDHGHDGDHGDHGHDGHDGH", phonenbr);
            recorder = new MediaRecorder();
            recorder.setAudioSource(MediaRecorder.AudioSource.MIC);                   
            recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);                   
            recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);                   
            recorder.setOutputFile(getFilename());
            recorder.prepare();
            recorder.start();
            recordstarted = true;
            telManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

        final PhoneStateListener phoneListener = new PhoneStateListener()
        {
            @Override
            public void onCallStateChanged(int state, String incomingNumber) {
                try {
                    switch (state) {
                        case TelephonyManager.CALL_STATE_RINGING: {
                            // 
                            break;
                        }
                        case TelephonyManager.CALL_STATE_OFFHOOK: {
                            // 
                            break;
                        }
                        case TelephonyManager.CALL_STATE_IDLE: {
                            if (recordstarted) {
                                recorder.stop();
                                recordstarted = false;
                            }
                            break;
                        }
                        default: { }
                    }
                } catch (Exception ex) {
                }
            } 
        };

        telManager.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE);
    }
}
private String getFilename(){                  
    String filepath = Environment.getExternalStorageDirectory().getPath();  
    File file = new File(filepath,AUDIO_RECORDER_FOLDER);                    
    if(!file.exists()){                          
        file.mkdirs();                  
    }

    return (file.getAbsolutePath() + "/" + phonenbr + System.currentTimeMillis() + ".mp4");   
}
}

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >

    <receiver android:name=".CallRecorder" android:enabled="true">
<intent-filter android:priority="1000">
    <action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>

    <activity
        android:name=".RecorderActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
  • 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-16T17:09:47+00:00Added an answer on June 16, 2026 at 5:09 pm
    BroadcastReceiver receiver = new CallRecorder();
    

    in Youractivity.onStart() :

    IntentFilter intentFilter = new ItentFilter("some_string-to_call_receiver");
    registerReceiver(receiver, intentFilter);
    

    and in Youractivity.onStop() :

    uregisterReceiver(receiver);
    

    and call your receiver everywhere:

    sendBroadcast(new Intent("some_string-to_call_receiver"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have no code to really display here, since I have not been able
What's the proper syntax here? If (@timestamp < (Select PromoStartTimestamp From @promo)) RAISERROR('Code not
I am not able to call a function in cpp file from c file
I am not able to call web service(asmx) from jQuery function. It is saying
What am I doing wrong here? Declare @starttimestamp datetime = getdate(); RAISERROR(N'Code not valid
Here's my code that is not working: print To: ; my $to=<>; chomp $to;
Code is not running on .click when I have this: $(.cancel).click(function() { alert(got here);
Got this line of code here but its not working. private void Button_Click(object sender,
I have some code here which works perfectly in firefox but not in chrome
I have a piece of code here that does not work despite me using

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.