当前位置:  编程技术>移动开发
本页文章导读:
    ▪coverflow(保藏)        coverflow(收藏) jhsdfdfskkhdfs ......
    ▪ 雷同class的startactivity使用Intent.FLAG_ACTIVITY_MULTIPLE_TASK        相同class的startactivity使用Intent.FLAG_ACTIVITY_MULTIPLE_TASK void android.content.Context.startActivity(Intent intent)Launch a new activity. You will not receive any information about when the activity exits. Note that if this method is bei.........
    ▪ Context的差异       Context的区别 引用In a regular Android application, you usually have two kinds of Context, Activity and Application. Reading the article a little bit further tells about the difference between to the two and why you might want to consider using t.........

[1]coverflow(保藏)
    来源: 互联网  发布时间: 2014-02-18
coverflow(收藏)
jhsdfdfskkhdfs

    
[2] 雷同class的startactivity使用Intent.FLAG_ACTIVITY_MULTIPLE_TASK
    来源: 互联网  发布时间: 2014-02-18
相同class的startactivity使用Intent.FLAG_ACTIVITY_MULTIPLE_TASK
void android.content.Context.startActivity(Intent intent)
Launch a new activity. You will not receive any information about when the activity exits.

Note that if this method is being called from outside of an android.app.Activity Context, then the Intent must include the Intent.FLAG_ACTIVITY_NEW_TASK launch flag. This is because, without being started from an existing Activity, there is no existing task in which to place the new activity and thus it needs to be placed in its own separate task.

This method throws ActivityNotFoundException if there was no Activity found to run the given Intent.

Parameters:
intent The description of the activity to start.
Throws:
ActivityNotFoundException
See Also:
PackageManager.resolveActivity

    
[3] Context的差异
    来源: 互联网  发布时间: 2014-02-18
Context的区别
引用

In a regular Android application, you usually have two kinds of Context, Activity and Application.

Reading the article a little bit further tells about the difference between to the two and why you might want to consider using the application Context (Activity.getApplicaitonContext()) rather than using the Activity context ("this"). Basically the Application context is associated with the Applicaiton and will always be the same throughout the life cycle of you app, where as the Activity context is associated with the activity and could possible be destroyed many times as the activity is destroyed during screen orientation changes and such.

I couldn't find really anything about when to use getBaseContext() other than a for a one liner from Dianne Hackborn, one of the Google engineers working on the Android SDK:

Don't use getBaseContext(), just use the Context you have.

That was from a post on the android-developers newsgroup, you may want to consider asking your question there as well because a handful of the people working on Android actual monitor that newsgroup and answer questions.

So overall it seems preferable to use the global application context when possible.


I got bad window token errors when using application context to Progress Dialog. So i used activity context instead.


在一般android程序中,通常有两种类型的Context:Activity类型以及Application类型。

通过更深的了解,你也许会在使用Application类型的Context时比使用Activity类型的更小心。基本上,Application类型的Context会伴随程序的整个生命周期,而Activity类型的Context则与Activity的状态相关,它会随着Activity的消亡而消亡。例如当屏幕方向发生变化时。


我找不到更多关于getBaseContext()的相关用法,除了google Android SDK工程师 Dianne Hackborn的一句话
不要使用getBaseContext(),使用你手头上的Context。

这句话来自android-developers 新闻组,许许多多的android开发者都在关注着新闻组,你也可以在那里提出自己的问题,有人会回答。

所以总的来说最好还是尽可能的使用Application类型的context。
我在使用ProgressDialog的时候使用 Application类型的Context 遇到了 bad window token errors。然后我用Activity类型的Context替代

    
最新技术文章:
▪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,