【发布时间】:2018-08-29 01:18:18
【问题描述】:
我有四个活动(A、B、C、D),顺序可以是任何东西(取决于运行时的要求)
A 类的代码是这样的,我们从服务器 api 响应中获取活动名称并将其传递给公共类以移动到另一个活动 -
class A extends Activity{
// Other Code of Activity
int backCount = getbackCountFromResponse(); // by calling any service
String name = getActivityNameFromResponse(); // by calling any service
Move m = new Move(this);
m.go(name);
onBackPressed(){
// What will be the code to move back according to number of back count
}
}
B 类的代码是这样的,我们从服务器 api 响应中获取活动名称并将其传递给公共类以移动到另一个活动 -
class B extends Activity{
int backCount = getbackCountFromResponse(); // by calling any service
String name = getActivityNameFromResponse(); // by calling any service
Move m = new Move(this);
m.go(name);
onBackPressed(){
// What will be the code to move back according to number of back count
}
}
B 类的代码是这样的,我们从服务器 api 响应中获取活动名称并将其传递给公共类以移动到另一个活动 -
class C extends Activity{
// Other Code of Activity
int backCount = getbackCountFromResponse(); // by calling any service
String name = getActivityNameFromResponse(); // by calling any service
Move m = new Move(this);
m.go(name);
onBackPressed(){
// What will be the code to move back according to number of back count
}
}
B 类的代码是这样的,我们从服务器 api 响应中获取活动名称并将其传递给公共类以移动到另一个活动 -
class D extends Activity{
// Other Code of Activity
int backCount = getbackCountFromResponse(); // by calling any service
String name = getActivityNameFromResponse(); // by calling any service
Move m = new Move(this);
m.go(name);
onBackPressed(){
// What will be the code to move back according to number of back count
}
}
用于移动到任何活动的通用方法“go”的代码 -
class Move {
Context con;
public Move(Context con){
this.con = con;
}
public void go(String activityname)
{
Intent i = new Intent(con, activityname.class)
this.con.startActivity(i);
}
}
我想从当前位置删除计数来自服务的活动数量,我该如何删除。
【问题讨论】:
-
方程式混乱,看不懂!
-
我已经更新了问题请再次检查是否可以理解
-
@SamosysTechnologies 看看下面我的回答,希望对你有帮助。
标签: android android-activity stack