android.app.Activity阅读摘要,有时候会不会需要保持一些现场数据呢? 想让系统帮你退出到后台或者挂掉前做些前置保持工作吗,重点参考吧:

*
* @param savedInstanceState If the activity is being re-initialized after
* previously being shut down then this Bundle contains the data it most
* recently supplied in {@link #onSaveInstanceState}. <b><i>Note: Otherwise it is null.</i></b>
*
* @see #onStart
* @see #onSaveInstanceState
* @see #onRestoreInstanceState
* @see #onPostCreate
*/
protected void onCreate(@Nullable Bundle savedInstanceState) {
if (DEBUG_LIFECYCLE) Slog.v(TAG, "onCreate " + this + ": " + savedInstanceState);
if (mLastNonConfigurationInstances != null) {
mAllLoaderManagers = mLastNonConfigurationInstances.loaders;
}
if (mActivityInfo.parentActivityName != null) {
if (mActionBar == null) {
mEnableDefaultActionBarUp = true;
} else {
mActionBar.setDefaultDisplayHomeAsUpEnabled(true);
}
}
if (savedInstanceState != null) {
Parcelable p = savedInstanceState.getParcelable(FRAGMENTS_TAG);
mFragments.restoreAllState(p, mLastNonConfigurationInstances != null
? mLastNonConfigurationInstances.fragments : null);
}
mFragments.dispatchCreate();
getApplication().dispatchActivityCreated(this, savedInstanceState);
if (mVoiceInteractor != null) {
mVoiceInteractor.attachActivity(this);
}
mCalled = true;
}

/**
* Same as {@link #onCreate(android.os.Bundle)} but called for those activities created with
* the attribute {@link android.R.attr#persistableMode} set to
* <code>persistAcrossReboots</code>.
*
* @param savedInstanceState if the activity is being re-initialized after
* previously being shut down then this Bundle contains the data it most
* recently supplied in {@link #onSaveInstanceState}.
* <b><i>Note: Otherwise it is null.</i></b>
* @param persistentState if the activity is being re-initialized after
* previously being shut down or powered off then this Bundle contains the data it most
* recently supplied to outPersistentState in {@link #onSaveInstanceState}.
* <b><i>Note: Otherwise it is null.</i></b>
*
* @see #onCreate(android.os.Bundle)
* @see #onStart
* @see #onSaveInstanceState
* @see #onRestoreInstanceState
* @see #onPostCreate
*/
public void onCreate(@Nullable Bundle savedInstanceState,
@Nullable PersistableBundle persistentState) {
onCreate(savedInstanceState);
}

/**
* The hook for {@link ActivityThread} to restore the state of this activity.
*
* Calls {@link #onSaveInstanceState(android.os.Bundle)} and
* {@link #restoreManagedDialogs(android.os.Bundle)}.
*
* @param savedInstanceState contains the saved state
*/
final void performRestoreInstanceState(Bundle savedInstanceState) {
onRestoreInstanceState(savedInstanceState);
restoreManagedDialogs(savedInstanceState);
}

/**
* The hook for {@link ActivityThread} to restore the state of this activity.
*
* Calls {@link #onSaveInstanceState(android.os.Bundle)} and
* {@link #restoreManagedDialogs(android.os.Bundle)}.
*
* @param savedInstanceState contains the saved state
* @param persistentState contains the persistable saved state
*/
final void performRestoreInstanceState(Bundle savedInstanceState,
PersistableBundle persistentState) {
onRestoreInstanceState(savedInstanceState, persistentState);
if (savedInstanceState != null) {
restoreManagedDialogs(savedInstanceState);
}
}

/**
* This method is called after {@link #onStart} when the activity is
* being re-initialized from a previously saved state, given here in
* <var>savedInstanceState</var>. Most implementations will simply use {@link #onCreate}
* to restore their state, but it is sometimes convenient to do it here
* after all of the initialization has been done or to allow subclasses to
* decide whether to use your default implementation. The default
* implementation of this method performs a restore of any view state that
* had previously been frozen by {@link #onSaveInstanceState}.
*
* <p>This method is called between {@link #onStart} and
* {@link #onPostCreate}.
*
* @param savedInstanceState the data most recently supplied in {@link #onSaveInstanceState}.
*
* @see #onCreate
* @see #onPostCreate
* @see #onResume
* @see #onSaveInstanceState
*/
protected void onRestoreInstanceState(Bundle savedInstanceState) {
if (mWindow != null) {
Bundle windowState = savedInstanceState.getBundle(WINDOW_HIERARCHY_TAG);
if (windowState != null) {
mWindow.restoreHierarchyState(windowState);
}
}
}

/**
* This is the same as {@link #onRestoreInstanceState(Bundle)} but is called for activities
* created with the attribute {@link android.R.attr#persistableMode} set to
* <code>persistAcrossReboots</code>. The {@link android.os.PersistableBundle} passed
* came from the restored PersistableBundle first
* saved in {@link #onSaveInstanceState(Bundle, PersistableBundle)}.
*
* <p>This method is called between {@link #onStart} and
* {@link #onPostCreate}.
*
* <p>If this method is called {@link #onRestoreInstanceState(Bundle)} will not be called.
*
* @param savedInstanceState the data most recently supplied in {@link #onSaveInstanceState}.
* @param persistentState the data most recently supplied in {@link #onSaveInstanceState}.
*
* @see #onRestoreInstanceState(Bundle)
* @see #onCreate
* @see #onPostCreate
* @see #onResume
* @see #onSaveInstanceState
*/
public void onRestoreInstanceState(Bundle savedInstanceState,
PersistableBundle persistentState) {
if (savedInstanceState != null) {
onRestoreInstanceState(savedInstanceState);
}
}

/**
* Restore the state of any saved managed dialogs.
*
* @param savedInstanceState The bundle to restore from.
*/
private void restoreManagedDialogs(Bundle savedInstanceState) {
final Bundle b = savedInstanceState.getBundle(SAVED_DIALOGS_TAG);
if (b == null) {
return;
}

final int[] ids = b.getIntArray(SAVED_DIALOG_IDS_KEY);
final int numDialogs = ids.length;
mManagedDialogs = new SparseArray<ManagedDialog>(numDialogs);
for (int i = 0; i < numDialogs; i++) {
final Integer dialogId = ids[i];
Bundle dialogState = b.getBundle(savedDialogKeyFor(dialogId));
if (dialogState != null) {
// Calling onRestoreInstanceState() below will invoke dispatchOnCreate
// so tell createDialog() not to do it, otherwise we get an exception
final ManagedDialog md = new ManagedDialog();
md.mArgs = b.getBundle(savedDialogArgsKeyFor(dialogId));
md.mDialog = createDialog(dialogId, dialogState, md.mArgs);
if (md.mDialog != null) {
mManagedDialogs.put(dialogId, md);
onPrepareDialog(dialogId, md.mDialog, md.mArgs);
md.mDialog.onRestoreInstanceState(dialogState);
}
}
}
}

时间: 2024-10-13 20:49:47

android.app.Activity阅读摘要,有时候会不会需要保持一些现场数据呢? 想让系统帮你退出到后台或者挂掉前做些前置保持工作吗,重点参考吧:的相关文章

android.app.Activity 的介绍

发现当前Android的资料不是很多,而且对于Activity的介绍也很少,所以把官方文档的android.app.Activity的介绍翻译了一下,加入了一些自己的理解.各位如果觉得我自己理解的不对,请无视.欢迎邮件讨论. android.app public class android.app.Activity java.lang.Object android.content.Context android.app.ApplicationContext    ViewInflate.Fact

使用javah生成.h文件, 出现无法访问android.app,Activity的错误的解决

在工程ndk22/bin/classes中 运行javah  com.cn.ndk22.Ndk22.Activity ,出现了.h文件 我在bin/classes目录中 ,就是无法访问, : 错误:无法访问android.app.Activity 找不到android.app.Activity 如下图所示 于是我cmd定位到ndk/src,中运行 javah com.heima.ndk.ndkActivity, 成功了就能成功了 ...我也不知道为什么.,如下图 总结:  使用javah生成.h

错误提示:&#39;……&#39; is not assignable to Android.app.Activity Manifest XML

1   问题描述:   针对这段代码: <activity android:name=".fragament.fragment_bulter" /> <activity android:name=".fragament.fragment_girl" /> <activity android:name=".fragament.fragment_user" /> <activity android:name=

命令行下使用javah命令生成.h文件,出现“错误: 无法访问android.app.Activity 找不到android.app.Activity的类文件”的解决方法

在学习NDK中,当我在项目的bin/classes目录下使用javah命令生成头文件时,出现了“错误: 无法访问android.app.Activity 找不到android.app.Activity的类文件”这个问题,如下 跳转到项目的src目录下使用javah命令,而不是在项目的bin/classes目录下使用javah命令即可! 无法访问android.app.Activity是说明没有引入android.jar包可以看看java -h里面的具体说明.其中有一个-bootclasspath

javah编译class文件找不到android.app.Activity的类文件

在android工程的根目录使用javah生成jni 头文件时候,报找不到android.app.Activity的类文件错误. 无法访问android.app.Activity是说明没有引入android.jar包 这边有两种方式可以解决: 第一种:在src目录执行命令,javah -d ../jni com.example.hellojni.HelloJni 其中-d表示输出目录 第二种:使用 bootclasspath参数,让他指定一个android.jar包 如:javah -class

错误:无法访问android.app.Activity 找不到android.app.Activity的类文件

[问题] 当在Android项目路径下,使用javah指令生成.h文件时,javah -classpath bin/classes -d jni com.example.myhellojni.MainActivity 出现--->错误:无法访问android.app.Activity 找不到android.app.Activity的类文件. 其中 -classpath bin:表示类的路劲 其中 -d jni: 表示生成的头文件存放的目录 其中 com.example.hellojni.Hell

Error: &quot;Call requires API level 11 (current min is 8): android.app.Activity#onCreateView&quot;

20151106: 通过默认设置创建一个项目,如图: 创建好了之后,打开 MainActivity.java 发现里面有报错,如图: 处理方式1: 将 AndroidManifest.xml 中的 “android:minSdkVersion="8"” 改为 11以上.但是老的手机可能会不支持. 处理方式2: 对比了 以前的老的代码,发现区别,MainActivity 的父类不同: 以前: “public class MainActivity extends Activity” 现在:

javah 错误: 无法访问android.app.Activity问题解决

cd /Users/musictom/Documents/source/ky/app/build/intermediates/classes/debug javah -jni -classpath /Users/musictom/Library/Android/sdk/platforms/android-25/android.jar:$ANDROID_HOME/extras/android/support/v4/android-support-v4.jar:$ANDROID_HOME/extra

javah命令的问题 最常见的 错误: 找不到类android.app.Activity。

一般是类的路径或者类找不到  直接进入src目录 通常用如下办法 -classpath . -bootclassapth  \sdk~\android.jar 这2点只要注意了 必须能生成 javah -jni -bootclasspath D:\Android\sdk\platforms\android-19\android.jar -classpath . com.awebing.jni.JNICall