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

  • Home
  • SEARCH
  • 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 3491134
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:36:02+00:00 2026-05-18T11:36:02+00:00

Main Activity Code. BroadcastExample.java package com.example.broadcast; import android.app.Activity; import android.os.Bundle; import android.util.Log; public class

  • 0

Main Activity Code. BroadcastExample.java

package com.example.broadcast;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class BroadcastExaple extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.d("PHONE", "Main Activity...Called");
        setContentView(R.layout.main);
        Log.d("PHONE", "After Mainf Activity...");
    }
}

MyBroadCastReceiver.java

package com.example.broadcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;


public class MyBroadcastReceiver extends BroadcastReceiver {
 @Override
 /*public void onReceive(Context context, Intent intent) {
  try{
  Log.d("Call BroadCAST","Calling Broad CAST");
  MyPhoneStateListener phoneListener = new MyPhoneStateListener();
  TelephonyManager telephony = (TelephonyManager) context
    .getSystemService(Context.TELEPHONY_SERVICE);
  telephony.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE);
  }
  catch(Exception e)
  {

  }

 }*/
  public void onReceive(Context context, Intent intent) {

       Log.d("Message", "Message Received");
    }


}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.example.broadcast" android:versionCode="1"
 android:versionName="1.0">
 <uses-prmission android:name="android.permission.READ_PHONE_STATE" />
 <uses-permission android:name="android.permission.CALL_PHONE"/>
 <application android:icon="@drawable/icon" android:label="@string/app_name">
  <activity android:name=".BroadcastExaple" 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=".MyBroadcastReceiver">
   <intent-filter>
    <action android:name="android.intent.action.PHONE_STATE" />
   </intent-filter>
   </receiver>

 </application>


 <uses-sdk android:minSdkVersion="7" />

</manifest> 

Program doesn’t enter into the onReceive Mathod of MyBroadCastReceiver class.

  • 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-18T11:36:02+00:00Added an answer on May 18, 2026 at 11:36 am

    First, i suggest you to format your code here. So that people here will be glad to read your problem code.
    Your code list above does NOT register any BroadcastReceiver to the system. You’d better to check out ApiDemo for more details.

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

Sidebar

Related Questions

The following is my code for SettingsActivity.java. The main activity starts this activity by
I use XML output in my app. So basically the main activity just tells
Trying to do the following (code is in the main activity): private MenuItem mainMenuSync
I have a an app whose Main activity shows a GLSurfaceView . Every time
I have an app with 2 activities, the preference and the main activity, I
I have an activity 'A' which is called from Main activity every second until
I have a simple main activity with 3 buttons, and a background service that
I have a main activity and a sub activity. The main activity starts the
I have following code: public class readSensorsData extends Activity implements SensorListener { /** Called
So I've created an Activity subclass called CustomTitlebarActivity. Essentially, each main activity in my

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.