简体   繁体   English

Android:安装后检测应用程序

[英]Android: detetct app after installation

I am downloading an Android app from a server and installing it. 我正在从服务器下载Android应用程序并进行安装。 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: 然后,创建一个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.

相关问题 安装后应用程序未保持状态 - Xamarin android - App is not maintaining the state after installation - Xamarin android Flutter:安装后 Android 应用出现问题 - Flutter: problems with Android app after installation 重新安装Android App后,应用程序会收到旧安装的通知 - After reinstalling Android App the App gets notifications meant for the old installation 应用安装后如何自动为Android应用创建快捷方式 - how to create shortcut for android app automatically after app installation 在Android中安装应用程序后如何显示欢迎屏幕 - How to display welcome screen after the installation of the app in Android 安装Android应用后仅首次运行活动 - Run Activity only for First time after installation of app Android 从通知栏启动Android应用程序:安装后 - Launching an Android app from notification bar : Just after installation 成功构建和APK安装后,Android Studio App在运行时崩溃 - Android Studio App crashes on run after successful build and apk installation 拒绝后重新允许通过无线调试安装应用程序 | 安卓 - Re allow app installation over wireless debugging after denying it | Android 仅在首次安装应用程序后创建的文件 - ANDROID - File created only after first installation of the app - ANDROID
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM