繁体   English   中英

Android:安装后检测应用程序

[英]Android: detetct app after installation

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

把它放在你的清单中:

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

然后,创建一个YourReceiver类并输入以下内容:

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


}

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM