Service異常:Service Intent must be explicit
今天在做AIDL的時候,碰到這麼一個異常:
java.lang.IllegalArgumentException: Service Intent must be explicit
翻譯過來就是——非法引數異常:服務意圖必須是明確的。
這個異常在5.0之前是沒有的,估計是為了安全考慮。既然異常提示為服務意圖必須是明確的,那麼就設定為明確的,之前的程式碼為:
public void onReceive(Context context, Intent intent) {
Intent serviceIntent = new Intent();
serviceIntent.setAction("com.duk3r.eortologio2.MyService");
context.startService(serviceIntent);
}
改為如下程式碼即可:
Intent serviceIntent = new Intent(context,MyService.class);
context.startService(serviceIntent);
或者:
Intent bi = new Intent("com.duk3r.eortologio2.MyService");
bi.setPackage("com.duk3r.eortologio2");
問題得到解決。
相關文章
- Android Intent ServiceAndroidIntent
- 異常 This application has no explicit mapping for /error so yAPPError
- Service 層異常拋到 Controller 層處理還是直接處理?Controller
- 【服務匯流排 Azure Service Bus】Service Bus在使用預提取(prefetching)後出現Microsoft.Azure.ServiceBus.MessageLockLostException異常問題ROSException
- Service
- 部署在IIS中服務出現異常 Failed to load resource: the server responded with a status of 503 (Service Unavailable)AIServer
- Android ServiceAndroid
- k8s之Service詳解-Service使用K8S
- systemd service unit
- 深入掌握service
- Service Worker初探
- Android Service SecurityAndroid
- What is a service mesh?
- Service Locator 模式模式
- Service詳解
- 建立windows serviceWindows
- Android Service生命週期 Service裡面的onStartCommand()方法詳解Android
- 【應用服務 App Service】App Service 新手資料包APP
- Service呼叫其他Service的private方法, @Transactional會生效嗎(上)
- 【Azure Bot Service】部署Python ChatBot程式碼到App Service中PythonAPP
- Service啟動流程
- Service銷燬流程
- 認識 Service Worker
- Guide to Database as a Service (DBaaS)GUIIDEDatabase
- Alexa Voice Service 概述
- 清晰地理解Service
- 8.2 Service3
- Service Mesh模式起源模式
- 2.4.1 Service Creation in a CDB
- 如何使用 Service 模式模式
- Spring Web Service教程SpringWeb
- Service Mesh 介紹
- Laravel 2.3 Service ProviderLaravelIDE
- Angular service 詳解Angular
- Android Service完全解析Android
- Kubernetes Service之ClusterIP
- Kubernetes實驗 Service
- Android Service重啟恢復(Service程式重啟)原理解析Android
- 【Azure微服務 Service Fabric 】使用az命令建立Service Fabric叢集微服務