android中使用前进后退的方法

可以用Intent.FLAG_ACTIVITY_REORDER_TO_FRONT启动一个activity吧,会把之前的load过的activity调出来,不需要重新load

Intent i = new Intent(B.this, C.class);
 i.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); //什么含义
 i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); //什么含义
startActivity(i);

从Service往Activity跳转时,要将Intent的Flag设置为FLAG_ACTIVITY_NEW_TASK才可以。

ERROR/AndroidRuntime(192): java.lang.RuntimeException: Unable to start receiver com.test.hmenu.HMenuReceiver: android.util.AndroidRuntimeException: Calling startActivity () from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

程序中有时用R去引用某个对象会出现错误,这时要在import中查看这个R是从哪个包里导入的。

R存在于3个地方

1.android.R系统自带。

2.存在于自己的某个package中,如果其他package中的类想使用R,必须import com.tour.activity.R;导入才行。

原文地址:https://www.cnblogs.com/pandans/p/1880526.html