草庐IT

hello_services

全部标签

Android Asynctask vs Runnable vs timertask vs Service

这些方法(类)有什么区别?我想运行一个每5秒运行一次的应用程序,完成后清除内存并且当cpu处于待机模式时,您可以运行该应用程序。这样应用就不会绑定(bind)到唤醒锁。问候,沙夫卡特 最佳答案 前三个之间的区别只是为您完成的工作量。还有一个Service是fundamentalAndroidapplicationcomponent.AsyncTask作为一个便利类,用于在新线程上做一些工作,并在完成后在调用它的线程(通常是UI线程)上使用结果。它只是一个包装器,它使用了几个可运行对象,但处理了创建线程和处理线程之间的消息传递的所有复

Android java.lang.IllegalArgumentException : No such service ComponentInfo JobScheduler

我试图创建一个简单的JobScheduler作业,只是为了看看它是如何工作的。但我在运行时不断收到此异常,我无法弄清楚,因为我一步一步按照指南进行操作。这是我的电话:ComponentNamecomponentName=newComponentName(getApplicationContext(),TestService.class);JobInfojobInfo=newJobInfo.Builder(1,componentName).setPeriodic(300000).setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY).build(

Android L Youtube API - IllegalArgumentException : Service Intent must be explicit

我知道在L上我只能绑定(bind)声明为显式的服务。在我的应用程序中,我目前正在使用YoutubeAPI,当在带有L的设备上运行时,我总是会收到此错误java.lang.IllegalArgumentException:ServiceIntentmustbeexplicit:Intent{act=com.google.android.youtube.api.service.START}如何解决这个问题,让YoutubeAPI也可以在L上运行? 最佳答案 有一个新版本的YoutubeAPI(1.2.1)可以解决这个问题。可以从here

android - 线程运行时在 Service 中调用 stopSelf()

假设我的Service的onStart()处理程序中有代码来启动一个线程来做一些事情,然后调用stopSelf()。stopSelf()在线程完成之前被调用。究竟会发生什么?我自己对此进行了测试,并且我的线程会继续执行直到完成。Android是否听到stopSelf()调用,但将其推迟到线程完成?@OverridepublicvoidonStart(Intentintent,intstartid){newThread(newRunnable(){publicvoidrun(){//TODOsomelongrunningoperation}}).start();stopSelf();}

android - 在哪里可以找到有关 Android 的 "service call"shell 命令的信息?

使用adbshell或设备上的终端模拟器,输入此将清除所有通知(需要su)servicecallnotification1这将发送一条短信(不需要su)servicecallisms5s16"PhoneNumber"i320i320s16"BodyText"在哪里可以了解有关服务调用的更多信息?我找到了thisquestion并欣赏答案对所有含义的分割。但是我在哪里可以找到关于notification2可能试图调用的方法的信息?运行servicecall不完整并打印出这个用法:Usage:service[-h|-?]servicelistservicecheckSERVICEservi

android - 项目树中的 google-services.json 位置

我正在关注本手册,但不确定应该将文件google-services.json准确复制到哪里?有许多文件夹包含一个app文件夹,我正在尝试为androidwear开发它。任何指南都会非常棒。到目前为止,我把它放在这里:链接到tutorial 最佳答案 正在为Android应用程序配置Firebase,它对这些提供了很好的描述。正如公认的答案所说,我应该放在app文件夹中。添加图像以更好地了解放置位置和所需配置。 关于android-项目树中的google-services.json位置,我

Android:将参数从Activity传递给Service

我通过这种方式绑定(bind)到服务:Activity类:ListenLocationServicemService;@OverridepublicvoidonCreate(BundlesavedInstanceState){...Intentintent=newIntent(this,ListenLocationService.class);intent.putExtra("From","Main");bindService(intent,mConnection,Context.BIND_AUTO_CREATE);...}privateServiceConnectionmConnec

android - Gradle 错误 : Unexpected inputs: android. gms:play-services

在运行时显示错误Gradle中的错误:错误:任务':app:transformClassesWithInstantRunForDebug'执行失败。Unexpectedinputs:ImmutableJarInput{name=com.google.android.gms:play-services-basement:9.0.0,file=/home/nawaf/AndroidStudioProjects/YugiohDeckBuilder/app/build/intermediates/transforms/profilers-transform/debug/43.jar,conte

android - 更新后 - 错误 :Failed to find: com. google.android.gms :play-services:5. 2.8

Gradle项目同步失败。更新androidSDK后出现此错误:Error:Failedtofind:com.google.android.gms:play-services:5.2.8我已检查更新的sdk位置是否已被AndroidStudio使用我已经安装了GoogleRepository并且AndroidSupportRepository也是最新的。还有一个ANDROID_HOME局部变量指向我实际使用的sdk 最佳答案 尝试使用com.google.android.gms:play-services:5.2.08而不是5.2.

android - Gradle 构建工具找不到 play-services-tasks.aar?为什么?

今天突然,我在AndroidStudio中运行我的应用时遇到了错误。它是:Error:Couldnotfindplay-services-tasks.aar(com.google.android.gms:play-services-tasks:15.0.1).Searchedinthefollowinglocations:https://jcenter.bintray.com/com/google/android/gms/play-services-tasks/15.0.1/play-services-tasks-15.0.1.aar我没有更改gradle文件中的任何内容,但它突然出现