当前位置:  编程技术>移动开发
本页文章导读:
    ▪Managing the Activity Lifecycle-Pausing and Resuming an Activity        Managing the Activity Lifecycle---Pausing and Resuming an Activity原文地址:https://developer.android.com/training/basics/activity-lifecycle/pausing.html --------------------------------------------- During normal app use, the foreground activity.........
    ▪ jquerymobile-13 替list提交搜索过滤        jquerymobile-13 为list提交搜索过滤在开发的时候如果list过长的话,在其中查找特定的一项是比较麻烦的,jquerymobile为我们直接提供了搜索的功能。我们就可以直接使用其功能查找我们想要的结.........
    ▪ 职业生涯碰到瓶颈-求教高人,拨云见日       职业生涯遇到瓶颈----求教高人,拨云见日2011年7月份毕业至今,虽然2011年由于公司的任务不重,当年虽然不断的开发程序,但是提高并不大。2012年开发转型做ios开发,刚开始对于程序开发很.........

[1]Managing the Activity Lifecycle-Pausing and Resuming an Activity
    来源: 互联网  发布时间: 2014-02-18
Managing the Activity Lifecycle---Pausing and Resuming an Activity

原文地址:https://developer.android.com/training/basics/activity-lifecycle/pausing.html

---------------------------------------------

During normal app use, the foreground activity is sometimes obstructed by other visual components that cause the activity topause. For example, when a semi-transparent activity opens (such as one in the style of a dialog), the previous activity pauses. As long as the activity is still partially visible but currently not the activity in focus, it remains paused.

在通常的app使用中,前台的activity有时会被另一个可见的部件阻塞从而引起该activity发生暂停。例如,当一个半透明的activity打开时(比如某种类型的对话框),那么之前的activity就暂停了。

However, once the activity is fully-obstructed and not visible, it stops (which is discussed in the next lesson).

但是,一旦activity被完全阻塞并且不再可见,它将会停止(在下一节课里讨论)。

As your activity enters the paused state, the system calls the onPause() method on yourActivity, which allows you to stop ongoing actions that should not continue while paused (such as a video) or persist any information that should be permanently saved in case the user continues to leave your app. If the user returns to your activity from the paused state, the system resumes it and calls theonResume() method.

当你的activty进入暂停阶段,系统在你的Activity中调用onPause()方法,这允许你停止正在进行的动作,而这些动作不应该在暂停时继续进行(例如一个视频),或是在用户离开你的app时保留任何应该永久保存的信息。如果用户从暂停状态返回到你的activity,系统将恢复它并调用onResume()方法。

Note: When your activity receives a call to onPause(), it may be an indication that the activity will be paused for a moment and the user may return focus to your activity. However, it's usually the first indication that the user is leaving your activity.

注意:当你的activity接收到一个onPause()调用时,它可能预示着activity将要被暂停一段时间,并且用户可能会返回你的activity。但是,这最可能表示用户正在离开你的activity。

Figure 1. When a semi-transparent activity obscures your activity, the system callsonPause() and the activity waits in the Paused state (1). If the user returns to the activity while it's still paused, the system callsonResume() (2).

图1.当一个半透明的acti阻塞你的activity时,系统调用onPause(),然后activity将在Paused状态等候(1)。如果在它暂停时,用户返回到activity,系统将调用onResume() (2)。

 

Pause Your Activity —— 暂停你的活动

 

When the system calls onPause() for your activity, it technically means your activity is still partially visible, but most often is an indication that the user is leaving the activity and it will soon enter the Stopped state. You should usually use theonPause() callback to:

  • Stop animations or other ongoing actions that could consume CPU.
  • Commit unsaved changes, but only if users expect such changes to be permanently saved when they leave (such as a draft email).
  • Release system resources, such as broadcast receivers, handles to sensors (like GPS), or any resources that may affect battery life while your activity is paused and the user does not need them.

当系统为你的activity调用onPause()时,在技术上意味着你的activity仍是部分可见的,但更多的情况下这意味着用户正在离开activity,并且将到达Stopped状态。通常情况下,你应该用onPause()回调函数来:

  • 停止动画或其他正在进行的会消耗CPU的动作。
  • 提交为保存的变化,但是只在当他们离开并且期望这些变化被永久保存时(例如邮件草稿)。
  • 释放用户不需要的系统资源,例如广播收音机,传感器手柄(像GPS),或是任何可能影响电池寿命的资源。

For example, if your application uses the Camera, theonPause() method is a good place to release it.

例如,如果你的应用使用Camera,onPause()方法是一个释放它的好地方。

@Override
public void onPause() {
    super.onPause();  // Always call the superclass method first

    // Release the Camera because we don't need it when paused
    // and other activities might need to use it.
    if (mCamera != null) {
        mCamera.release()
        mCamera = null;
    }
}

Generally, you should not use onPause() to store user changes (such as personal information entered into a form) to permanent storage. The only time you should persist user changes to permanent storage within onPause() is when you're certain users expect the changes to be auto-saved (such as when drafting an email). However, you should avoid performing CPU-intensive work during onPause(), such as writing to a database, because it can slow the visible transition to the next activity (you should instead perform heavy-load shutdown operations during onStop()).

通常,你不应该使用onPause()来将用户变化(例如键入表单的个人信息)永久存储。只有当你确定用户希望这些变化自动存储时(例如草稿邮件),你才应该在onPause()中永久保存这些变化。但是,你应该避免在onPause()中进行密集的CPU工作,例如向数据库写入数据,因为这会减慢向下一个activity的可视转换(相反的,你应该在onStop()中进行这些高负荷的关闭动作)。

You should keep the amount of operations done in the onPause() method relatively simple in order to allow for a speedy transition to the user's next destination if your activity is actually being stopped.

你应该保持onPause()中完成的操作的数目相对简单,以便当你的activity真的需要停止时,可以允许快速地向用户的下一个目标转换。

Note: When your activity is paused, the Activity instance is kept resident in memory and is recalled when the activity resumes. You don’t need to re-initialize components that were created during any of the callback methods leading up to the Resumed state.

注意:当你的activity暂停时,该Activity实例被驻留在内存中,并且在activity继续时被重新调用。你不需要重新初始化那些已经在任何回调函数中创建的部件。

 

Resume Your Activity —— 恢复你的活动

 

When the user resumes your activity from the Paused state, the system calls theonResume() method.

当用户从Paused状态返回你的activity时,系统调用onResume()方法。

Be aware that the system calls this method every time your activity comes into the foreground, including when it's created for the first time. As such, you should implementonResume() to initialize components that you release duringonPause() and perform any other initializations that must occur each time the activity enters the Resumed state (such as begin animations and initialize components only used while the activity has user focus).

你应该意识到,每次你的activity进入前台时,系统都会调用这个方法,包括当第一次创建它时。同样的,你应该实现onResume()来初始化你在onPause()释放的部件,并且执行那些在进入Resumed状态时必须出现的初始化动作(例如开始动画,初始化那些当activity获得用户聚焦时需要的部件)。

The following example of onResume() is the counterpart to theonPause() example above, so it initializes the camera that's released when the activity pauses.

下面onResume()的例子与上面的onPause()例子十分相似,因此它初始化在activity暂停时释放的照相机。

@Override
public void onResume() {
    super.onResume();  // Always call the superclass method first

    // Get the Camera instance as the activity achieves full user focus
    if (mCamera == null) {
        initializeCamera(); // Local method to handle camera init
    }
}

 


    
[2] jquerymobile-13 替list提交搜索过滤
    来源: 互联网  发布时间: 2014-02-18
jquerymobile-13 为list提交搜索过滤

在开发的时候如果list过长的话,在其中查找特定的一项是比较麻烦的,jquerymobile为我们直接提供了搜索的功能。我们就可以直接使用其功能查找我们想要的结果。为了实现这个功能我们只需要在ul中添加data-filter="true",这样jquerymobile就会自动添加一个过滤的搜索框,并且实现搜索功能了。下面给出一个例子代码:

<!DOCTYPE html>
<html>
<head>
<title>List Divider Example</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script>
</head>

<body>

<div data-role="page">

	<div data-role="header">
		<h1>My Header</h1>
	</div>
	
	<div data-role="content">
		<ul data-role="listview" data-inset="true" data-filter="true" data-filter-placeholder="Something">
		<li><a href="/blog_article/ray.html">Raymond Camden</a></li>
		<li><a href="/blog_article/scott.html">Scott Stroz</a></li>
		<li><a href="/blog_article/todd.html">Todd Sharp</a></li>
		<li><a href="/blog_article/dave.html">Dave Ferguson</a></li>
		<!-- following links all share the same url to keep things simple -->
		<li><a href="/blog_article/dave.html">Jeanne Camden</a></li>
		<li><a href="/blog_article/dave.html">Alexson Boudreaux</a></li>
		<li><a href="/blog_article/dave.html">Ben Forta</a></li>
		<li><a href="/blog_article/dave.html">Rachel Luxemburg</a></li>
		<li><a href="/blog_article/dave.html">Lynn Camden</a></li>
		<li><a href="/blog_article/dave.html">Noah Camden</a></li>
		<li><a href="/blog_article/dave.html">Jacob Camden</a></li>
		<li><a href="/blog_article/dave.html">Luke Skywalker</a></li>
		<li><a href="/blog_article/dave.html">Anakin Skywalker</a></li>
		<li><a href="/blog_article/dave.html">Moonpie Rockhead</a></li>
		<li><a href="/blog_article/dave.html">Lisa Spacestation</a></li>
		<li><a href="/blog_article/dave.html">Terrible Ricky</a></li>
		<li><a href="/blog_article/dave.html">Han Solo</a></li>
		</ul>
	</div>

	<div data-role="footer">
		<h4>My Footer</h4>
	</div>
		
</div>

</body>
</html>

显示效果如下(由于比较多没有完全显示,导致footer没有显示出来):


当我们输入了“r”后,footer显示出来了,显示效果如下:



2楼yuduliuyihui昨天 10:10哇,又更新了,你学新技术的速度好快啊,你的学习途径和资源是什么?能告诉我吗。Re: mengxiangyue昨天 20:11回复yuduliuyihuin网上一些外国的书籍,然后去看。我的英语水平不好,只能是使用有道一点一点的查,但是看过几本就容易多了。我们在项目中使用了jquerymobile所以接受快一点。1楼yuduliuyihui昨天 21:31嗯,技术发展日新月异,做技术的只能不断学习,终生学习,项目驱动是学习新技术的好方法。Re: mengxiangyue昨天 22:05回复yuduliuyihuin那一起努力吧

    
[3] 职业生涯碰到瓶颈-求教高人,拨云见日
    来源: 互联网  发布时间: 2014-02-18
职业生涯遇到瓶颈----求教高人,拨云见日

2011年7月份毕业至今,虽然2011年由于公司的任务不重,当年虽然不断的开发程序,但是提高并不大。2012年开发转型做ios开发,刚开始对于程序开发很有兴趣,希望在ios领域有所发展。而且随着时间的流逝,项目的积累。经过了三四个项目之后,感觉遇到了程序开发的瓶颈。因为开发ios程序感觉到无趣,没有挑战性了,新鲜感有所降低。开始进入了人生的迷茫期,对于职业生涯的困惑。

虽然也和其他人聊过,但是并没有找到解决的办法。近日,和部门架构师技术大牛进行沟通,向他阐述了我的困惑。经他指点,如拨云见日,收获非常大。对于职业生涯的发展也有了深刻的认识,maybe it can expand to life. 

While,what I focus about the software is only how to develop the application and complete it quickly. Then I can finish it to get the prize from my boss. The idea is always take my brans. But the wise man told me I should pay my main attention to the deeper way of the developing. Thinking the process of how the application is running. Not  only focus on the surface, but also get the nature of the process.

He did not suggest me to study the deep of ios ,but advise me QT and android. Because both of them are open source. Then I can read the source codes of the system.While now, I will list the points of the things.

QT:  1.Window server

   event loop

   while(!exit)

   {

            getEvent();

    processEvent();

   } 

2.signal/slot

3.IPC,QCopch,QSocket

Android: mainly about the Android framework

1.windows service

2.Message/Looper/Handler/Looper

3.Window/View

4.Binder IPC--- start activity/service Remote(all service) Binder is the key one

    the architecture thinking is extremely important for the software developer,especially for the architect. If the software developer understand these knowledge, then he may find the route to the architect,or the architect can not design the good architecture of the system and the system may have plenty of leak.

  


    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3