Android Warning: Exported activity does not require permission

Sometimes even the warnings get annoying because you just can’t find anything wrong in your code. While working on an android app, you may encounter this warning so you better get rid of it by just following the easy steps.

Usually there are more than one way to debug a bug. All you need to do is to keep googling until you find the right one for you. So I decided to put all the approaches in a single post just to save time.

Approach 1:
———–
Okay so here goes the first method
If you are using eclipse, just select your project root folder in the “project explorer panel and select “Project” -> “CLean…” from the top menu. There you go! You fixed the warnings.

Approach 2:
———–
Go to your project and open Android Manifest file. Lets assume that your manifest file contains an activity that has the details as follows

<activity 
  android:name=".MainActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <data android:scheme="http" android:host="example.com" />
    </intent-filter>
</activity>

Add the following lines as shown below.

<activity
android:name=".MainActivity"
android:exported="false">
<intent-filter>

         <action android:name="android.intent.action.MAIN" />
         <data android:scheme="http" android:host="example.com" />

    </intent-filter>
</activity>

Wonder why we did this? Well… It means that other (arbitrary) applications the user has on his phone can bind to your Service and call whatever method they please that is exposed through your AIDL interface.
Approach 3
—————

Remove “intent filters” because it is not needed there!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s