views:

101

answers:

1

Hi,

I have written an Android Application and the generated .APK file I uploaded in Android Market. So, a User can download that apk and install in his device.How can I restrict my apk to launch , if he calls from other application through Intent. That means my application should not respond to any intents from other outside Applications.

Is there any possible way to restrict my application's launch from intents from other application.? I will be waitinig for reply. Thanks in Advance,

+2  A: 

Try setting android:exported="false" to all activities defined at AndroidManifest.xml

That's from activity element description:

android:exported Whether or not the activity can be launched by components of other applications — "true" if it can be, and "false" if not. If "false", the activity can be launched only by components of the same application or applications with the same user ID. The default value depends on whether the activity contains intent filters. The absence of any filters means that the activity can be invoked only by specifying its exact class name. This implies that the activity is intended only for application-internal use (since others would not know the class name). So in this case, the default value is "false". On the other hand, the presence of at least one filter implies that the activity is intended for external use, so the default value is "true". This attribute is not the only way to limit an activity's exposure to other applications. You can also use a permission to limit the external entities that can invoke the activity (see the permission attribute).

Also here are good paragraphs about application permissions http://developer.android.com/intl/zh-TW/guide/topics/security/security.html#declaring I guess you can use that to restrict access to your app.

Konstantin Burov
@Konstantin Burov: Except that doing this will mean the home screen won't be able to launch the app.
CommonsWare
Yes, if I keept android:exported as true, Home screen is not able to launch the app.Then how should I proceed to achieve my requirement?Thanks in Advance
Android_programmer_camera
Read about permissions, that looks to be more correct way.
Konstantin Burov
Also why do you want restrict the main activity? That makes no sense.
Konstantin Burov