Skip to main content

Home/ Android Dev/ Group items tagged service

Rss Feed Group items tagged

Simon Pan

Service | Android Developers - 0 views

  • avoid
    • Simon Pan
       
      如果在Service裡做了要做的事,它們還是在UI thread裡做事情,而不是在什麼別的thread做事情。但是Service很特別,它又不是一個執行緒,因為通常Service要做的事情都蠻耗時的,萬一Service算是執行緒,那麼就會強碰到系統的ANR機制。
  • A facility for the application to tell the system about something it wants to be doing in the background
  • A facility for an application to expose some of its functionality to other applications.
  • ...3 more annotations...
  • two reasons
  • depending on the value they return from onStartCommand(): START_STICKY is used for services that are explicitly started and stopped as needed,
  • then take the service out of the started state and don't recreate until a future explicit call to Context.startService(Intent).
Vincent Tsao

Android Cloud to Device Messaging Framework - Google Projects for Android - 1 views

  • It allows third-party application servers to send lightweight messages to their Android applications. The messaging service is not designed for sending a lot of user content via the messages. Rather, it should be used to tell the application that there is new data on the server, so that the application can fetch it. C2DM makes no guarantees about delivery or the order of messages. So, for example, while you might use this feature to tell an instant messaging application that the user has new messages, you probably would not use it to pass the actual messages. An application on an Android device doesn’t need to be running to receive messages. The system will wake up the application via Intent broadcast when the the message arrives, as long as the application is set up with the proper broadcast receiver and permissions.
  • It uses an existing connection for Google services. This requires users to set up their Google account on their mobile devices.
  • C2DM imposes the following limitations: The message size limit is 1024 bytes. Google limits the number of messages a sender sends in aggregate, and the number of messages a sender sends to a specific device
  • ...1 more annotation...
  • The ClientLogin token authorizes the application server to send messages to a particular Android application. An application server has one ClientLogin token for a particular 3rd party app, and multiple registration IDs. Each registration ID represents a particular device that has registered to use the messaging service for a particular 3rd party app.
Kiran Kuppa

AndroidAnnotations - 0 views

  •  
    Using Java annotations, developers can show their intent and let AndroidAnnotations generate the plumbing code at compile time. Few Features are * Dependency injection: inject views, extras, system services, resources, ... * Simplified threading model: annotate your methods so that they execute on the UI thread or on a background thread. * Event binding: annotate methods to handle events on views, no more ugly anonymous listener classes! * REST client: create a client interface, AndroidAnnotations generates the implementation. * AndroidAnnotations provide those good things and even more for less than 50kb, without any runtime perf impact!
Vincent Tsao

What is OSGi (Open Service Gateway Initiative)? - Definition from WhatIs.com - 0 views

  • OSGi (Open Service Gateway Initiative) is Java framework for developing and deploying modular software programs and libraries
Vincent Tsao

[Android研究手记3]组件间的交互和进程间IPC通信 « hkbarton - Undefined Life - 2 views

  • 基于Unix(Linux)的系统都有一个很优秀的传统,就是倡导非常轻便的进程间通信(IPC)机制;倡导进程通过IPC来互相协作;倡导功能单一,小巧而强壮的进程,而不是又大又复杂的“万金油”
  • Android的组件和进程间通信都建立在一种基于称为Intent的消息基础之上。Intent就是一种消息,它包含了两个重要的内容:1. 消息的目的,即这个消息是发给哪个组件的?(消息的目的中不会包含“消息是发给哪个进程”这样的信息,这里Android有意淡化进程的概念,而只让我们关心组件,因为了解太多关于进程的具体信息会加大复杂度,而又如何做到进程间的消息传递呢?下文会说到一种Android中关于这点比较特别的设计方式,我认为是一种简捷有用又符合手机特点的设计);2. 消息所携带的数据内容,即需要传递给目标的数据。下面是一个简单的利用Intent来启动一个Service并向其传递数据的代码示例
  • 这种模式的消息由于已经确切知道了消息目标的确切信息,所以只适用于同一进程内的不同组件之间通信,例如打开一个子窗体,和同一进程中的service通信等。对应的,隐式消息就一般用于跨进程的通信了,隐式消息没有确定的消息目的地,除了数据外,隐式消息只是包含了一些用于表征消息特征的描述字段
  • ...1 more annotation...
  • 隐式消息这个设计简单有效,它忽略了进程的细节,让IPC在一个更高的更接近人脑思维模式的层次工作,让系统中的不同进程协作看起来就像是同一程序中的协作一样,这种简单的IPC机制在很大的程度上鼓励我们和其他进程协作,通过协作的进程来完成一个复杂的任务,而不是把什么功能都做到一个大而全的程序里面
Vincent Tsao

ysl 的程式天堂 - Android 應用開發‧研究‧與諮詢: 深入研究 IntentService 原始碼 - 1 views

  • 如果你呼叫 startService() 多次,每一次的呼叫都會被轉成一個 message,並放在 mServiceLooper 的 message queue 中,等待被服務。一個 message 所對應的工作被完成後,才會繼續服務下一個工作。所以,這些等待被服務的工作,並不是一起並行 (Concurrent) 的,而是循序執行。
  • 從研究這個 IntentService 的原始碼,我們可以學到如何運用簡單的 pattern (Service + Handler + HandlerThread),幫我們更簡易與有系統地,完成我們所想要做的事
  • 最後我們先前說過,在 IntentServcie 中等待被服務的工作,並不會被一起並行,而是循序執行。如果你今天想要這些等待被服務的工作,能夠一起被並行,在研讀完這個 IntentService 的原始碼後,你自己知不知道如何寫個可支援並行工作的 IntentService? 提示:可以用 Service + AsyncTask 的組合
Simon Pan

Application Fundamentals | Android Developers - 0 views

  • passes
  • When onReceive() returns
  • by the system at any time
  • ...13 more annotations...
  • to start a service
  • presents
  • memory paging state
  • Broadcast receiver lifecycle
  • The activity at the top of the stack is one that's currently running
  • The root activity in the stack is the one that began the task
  • Suppose
  • keeping both activities in the same task.
  • Tasks
  • A task is a stack of activities, not a class or an element in the manifest file.
  • The current task goes into the background and the root activity for the new task is displayed.
  • Rather
  • the previous activity in the same task is displayed.
Vincent Tsao

The CommonsBlog - Activity or Notification via Ordered Broadcast - 0 views

  • I’ve run into the following generalized question a lot recently: I have an event that occurs in the background. I want to update my activity, if the activity is on the screen. Otherwise, I want to raise a Notification.
  • Hence, the recipe for the activity-or-Notification pattern is: Define an action string you will use when the event occurs that you want to go to the activity or notification (e.g., com.commonsware.java.packages.are.fun.EVENT). Dynamically register a BroadcastReceiever in your activity, with an IntentFilter set up for the aforementioned action string and with a positive priority (the default priority for a filter is 0). This receiver should then have the activity do whatever it needs to do to update the UI based on this event. The receiver should also call abortBroadcast() to prevent others from getting it. Be sure to register the receiver in onStart() or onResume() and unregister the receiver in the corresponding onStop or onPause() method. Register in your manifest a BroadcastReceiver, with an <intent-filter> set up for the aforementioned action string. This receiver should raise the Notification. In your service (e.g., an IntentService), when the event occurs, call sendOrderedBroadcast(). And that’s it. If the activity is on-screen, its receiver will be registered, so it will get the event, process it, and cancel the broadcast. If the activity is not on-screen, its receiver will not be registered, so the event will go to the default handler, in the form of your manifest-registered BroadcastReceiver, which will raise the Notification.
Vincent Tsao

A Sneak Preview Of Dropbox's Upcoming Android App - 0 views

  • For those of you that haven’t tried Dropbox, it’s a service that makes it remarkably easy to share files between multiple computers (it means you don’t have to keep emailing files between your home and work computers, or rely on a clunky USB stick). It’s also great for collaboration — we’ve been using it around the TechCrunch office to share files for years now
Vincent Tsao

chrometophone - Project Hosting on Google Code - 0 views

  • Google Chrome to Phone Extension is a project consisting of a Chrome Extension, Android App, and supporting AppEngine server that enables users to send links from their Chrome desktop browser to their Android device using Android's Cloud to Device Messaging service.
Vincent Tsao

Will Android phones ever achieve iPhone's level of polish and usability? | TiPb - 1 views

  • Current Instapaper and former Tumblr developer Marco Arment wonders out loud if Google Android phones can ever achieve the levels of usability and polish Apple’s iPhone has arguably had since day one
  • Android will continue to exhibit what Google does best: great low-level engineering and tight integration with Google’s other services. But it’s never going to be Apple-like in user experience, polish, or design. Attention to detail, like most facets of truly good design, can’t be (and never is) added later. It’s an entire development philosophy, methodology, and culture
Vincent Tsao

Introducing Droid-Fu for Android: BetterActivity, BetterService and BetterAsy... - 2 views

  • So the basic idea is: launch an AsyncTask making your service call, show a nifty progress dialog while the task thread is running, and have the task’s result be posted back to your activity once it completes. Cool, but what if the user decides to rotate the screen while your task is running? Or a phone call comes in, interrupting your app, and Android decides to kill it? Both these actions will effectively terminateyour activity, and recreate it when resuming (yes, a screen rotation kills your activity, very clever, isn’t it?). Unfortunately, any AsyncTask that was still running now holds a stale reference to your activity, because the restarted activity will be an entirely different object in memory (and it will go through onCreate(), as if the activity had started for the first time). I’m not entirely sure whether AsyncTask will actually post back the data to the old activity object (if it was a weak reference, it may already have been garbage collected), but in any case, your “new” activity will never see it, because it’s a different instance.
    • Vincent Tsao
       
      This situation always raise a FC bug, an alternative solution is IntentService + broadcast 
Vincent Tsao

避免Android开发中的ANR | Log4think - 0 views

  • AsyncTask要点 1、必须从主线程调用,或者线程中有Handler或Looper。 2、不要在一个可能会被另外一个AsyncTask调用的库里面使用AsyncTask(AsyncTask是不可重入的) 3、如果从一个activity中调用,activity进程可能会在AsyncTask结束前退出,例如: 用户退出了activity 系统内存不足 系统暂存了activity的状态留待后用 系统干掉了你的线程 如果AsyncTask中的工作很重要,应该使用……
  • IntentService 的好处 Acitivity的进程,当处理Intent的时候,会产生一个对应的Service Android的进程处理器现在会尽可能的不kill掉你 非常容易使用
  • 总结 离开主线程! 磁盘和网络操作不是马上就能完的 了解sqlite在干嘛 进度展示很好
1 - 15 of 15
Showing 20 items per page