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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:07:02+00:00 2026-05-27T03:07:02+00:00

I have application with BroadcastReceiver which listens to SD card mount/unmount, like: public class

  • 0

I have application with BroadcastReceiver which listens to SD card mount/unmount, like:

public class ExternalDatabaseRemovingBroadcastReceiver extends BroadcastReceiver
{
    private static final String TAG= ExternalDatabaseRemovingBroadcastReceiver.class.getName();

    public ExternalDatabaseRemovingBroadcastReceiver()
    {
        super();
    }

    @Override
    public void onReceive(Context context, Intent intent)
    {
        if(Me.DEBUG)
            Log.d(TAG, "SD card mount/unmount broadcast=" + intent.getAction());
        if(intent.getAction()==null)
            return;
        if(Intent.ACTION_MEDIA_UNMOUNTED.equalsIgnoreCase(intent.getAction()) ||
                Intent.ACTION_MEDIA_EJECT.equalsIgnoreCase(intent.getAction()) ||
                Intent.ACTION_MEDIA_SHARED.equalsIgnoreCase(intent.getAction()))
        {
              //blah-blah
        }
    }
}

Broadcast is declared in AndroidManifest as:

<receiver android:enabled="true"
          android:exported="true"
          android:name=".ExternalDatabaseRemovingBroadcastReceiver">
    <intent-filter>
        <action android:name="android.intent.action.MEDIA_MOUNTED"/>
        <action android:name="android.intent.action.MEDIA_UNMOUNTED"/>
        <action android:name="android.intent.action.MEDIA_SHARED"/>
        <data android:scheme="file"/>
    </intent-filter>
</receiver>

And now my problem. During device launch (either real or emulator) – my application unintentionally runs. I mean ActivityManager self runs it reporting:

11-22 08:56:52.239: INFO/ActivityManager(61): Start proc ru.ivanovpv.cellbox.android for broadcast ru.ivanovpv.cellbox.android/.ExternalDatabaseRemovingBroadcastReceiver: pid=288 uid=10034 gids={1015}

Please explain what’s goin on? And how to avoid application self running?

  • 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-27T03:07:03+00:00Added an answer on May 27, 2026 at 3:07 am

    It seems to me that upon booting the device, the SD card is mounted as well, which triggers your intent filter. If you don’t want this ‘initial’ mount to be registered by your app, you can perhaps ignore mounts that happen during the first x seconds of uptime. That may not be the most elegant solution, though…


    Edit: Now that I understand barmaley’s original intent, the solution is much simpler. Intent-filters in the Android manifest are meant to start your application when something external happens. If you only want to react to (un)mounts while your application is already running, just register your broadcastreceiver programmatically in Application.create and unregister it in Application.destroy using Context.registerReceiver and Context.unregisterReceiver respectively.

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

Sidebar

Related Questions

I have this Broadcast receiver registered public class NotifyAlarmBroadcast extends BroadcastReceiver{ public Context context;
In my Android application, I have a DefaultApplication class which extends android.app.Application , and
is the Application class instantiated when a BroadcastReceiver is called? I have some logic
In my application there are two class one is InternetActivity which only extends Activity
I have a blank HelloWorld Application: package tutorials.TestReceivers; import android.app.Activity; import android.os.Bundle; public class
I have application which uses Sherlock ActionBar package. The application uses platform-specific behavior for
I have application which needs to use a dll (also written by me) which
I have an application which is keeping a log of internally developed applications installed
I have Android application which is Sales Rep application.When he using the app first
I have an application which requires data to be fetched from a received message

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.