luo
luo

Reputation: 13

Specify the package name to call this app

my app AndroidManifest.xml

 <activity
    android:name="com.test.orc.IdentifyIdcards"
    android:screenOrientation="landscape" >
      <intent-filter>
                    <action android:name="com_test_orc_IdentifyIdcards" />

                    <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>
            </activity>

so any app can call my app by

Intent intent = new Intent();
intent.setAction("start_photo_identify_picture_activity");
startActivity(intent); 

but I limit only the package name is com.test.idcard can call my app, how to do it?

Upvotes: 1

Views: 377

Answers (2)

Mohammad Zarei
Mohammad Zarei

Reputation: 1802

You must change the way that they start your app .If they call your app and your app started with startActivityForResult, you can have the caller by using getCallingActivity() and with that, you can have the package name.

Upvotes: 0

sup4eli
sup4eli

Reputation: 324

You need to specify <permission> on the manifest, Specifically you want the

android:protectionLevel="signature"

Read more here: https://developer.android.com/guide/topics/manifest/permission-element.html

Upvotes: 1

Related Questions