Git Product home page Git Product logo

android-app-pause's Introduction

android-app-pause

This library simulates Application-level onPause() and onResume() life cycle events. But, what does that actually mean? For the purposes of this library, the following definitions apply:

An app is considered to be paused when the app is no longer visible to the user. By definition, this means that when an app is paused, none of the Activitys that belong to the app are visible to the user.

Along similar lines,

An app is considered to be resumed when at least one Activity from the app is visible to the user.

##How to Use

android-app-pause is provided as an Android Library project. To use it, follow these steps:

  1. Add android-app-pause as a dependent library to your Android Application Project.
  • Extend AbstractAppPauseApplication and override the methods onAppPause() and onAppResume().
  • For every Activity in your app:
    • Extend AbstractAppPauseActivity, instead of android.app.Activity.
    • (Optional): If you want device rotations to trigger app pauses, call setTreatRotationAsAppPause with a value of true.

Check out the sample project to see how it is used.

##New in v2.0 v1.0 of this library did not take into account the device rotations. Hence, when you rotated the device, onStop() would be called on all the activities, all clients would "un-bind", and your onAppPause() would be called followed by onAppResume().

v2.0 takes device rotations into account. By default, device rotations do not trigger app pause events. This behavior can be altered using the setTreatRotationAsAppPause(boolean) method.

##More Details For more details including implementation information and tips for contributors, please see the website.

##Contributing If you want to improve this library, fork away. Pull requests are welcome.

##Who uses this? If you are using this library in your app, please be kind enough to add your app to the list here.

##Credits The sample project uses AndroidAsync library by Koushik Dutta for running an HTTP Server.

###License

Copyright 2013 Kiran Rao

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

android-app-pause's People

Contributors

curioustechizen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

android-app-pause's Issues

Improve sample to demonstrate real world use case

The current sample app just prints Logs when the app resumes or pauses. Improve this to demonstrate a real world use case (like register/unregister some system broadcasts, or schedule/clear Alarm etc).

Clarify behaviour of library with respect to device orientation changes.

When a device orientation change happens, an Activity is destroyed and re-created. As a consequence, the app-pause may be triggered even while the device is being rotated. Whether this is acceptable or not again depends on the particular use case.

The library specification needs to clarify the expected behaviour during device orientation changes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.