I am downloading an Android app from a server and installing it. I want to detect when the installation is completed. I tried this link but it didn't work. Is there any other example?
Asked
Active
Viewed 173 times
1 Answers
2
Put this in your manifest:
<manifest>
....
<application>
....
<receiver android:name=".YourReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED">
</intent-filter>
</receiver>
</application>
</manifest>
Then, create a YourReceiver
class and put in the following:
public class YourReceiver extends BroadcastReceiver{
final static String TAG = "YourReceiver";
@Override
public void onReceive(Context context, Intent intent) {
Log.i(TAG, "Intent received!");
Uri data = intent.getData();
String pkgName = data.getEncodedSchemeSpecificPart();
if (pkgName.equals("some.app.name")) {
Log.i(TAG, "Package installed");
}
}
}

Nick
- 3,504
- 2
- 39
- 78