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?
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");
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.