当前位置: 编程技术>移动开发
本页文章导读:
▪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
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
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替代
引用
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替代
最新技术文章: