隐式启用Service崩溃问题

    xiaoxiao2021-03-26  24

    通过Intent隐式启用Service时发现程序总是奔溃

    intent = new Intent(); intent.setAction("com.study.study.service.MYSERVICE");

    后来根据AS友情提示:

    E/AndroidRuntime: FATAL EXCEPTION: main Process: com.study.study, PID: 9239 java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.study.study.service.MYSERVICE }

    发现不能这么简单的进行隐式启动,还必须要加上 intent.setPackage()。

    intent = new Intent(); intent.setAction("com.study.study.service.MYSERVICE"); intent.setPackage("com.study.study");
    转载请注明原文地址: https://ju.6miu.com/read-662243.html

    最新回复(0)