Android 安卓:安装后的Dettect应用程序

Android 安卓:安装后的Dettect应用程序,android,installation,detect,Android,Installation,Detect,我正在从服务器下载Android应用程序并安装它。我想检测安装何时完成。我试过了,但没用。还有其他的例子吗?把它放在你的清单中: <manifest> .... <application> .... <receiver android:name=".YourReceiver"> <intent-filter> <action android

我正在从服务器下载Android应用程序并安装它。我想检测安装何时完成。我试过了,但没用。还有其他的例子吗?

把它放在你的清单中:

<manifest>
    ....
    <application>
        ....
        <receiver android:name=".YourReceiver">
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_ADDED">
            </intent-filter>
        </receiver>
    </application>
</manifest>
}

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");
    }


}