Encountered a small problem, may be more an idiot, I do not know how we are treated
There are A, B, C three Activity, jump sequence is A-> B-> C,
A jump to the time B, A can not be finish off, but jumps to C, B, and how the A, B two finish off simultaneously Activity?
(PS: If you do not jump to C, B, A can press the back button to return to the page in the B page),
Solving ~ ~ Thank you
Reply:
1: The demand is very boring.
2: Try this, registered Intent in onCreate method of A & B's, in the C startup, onDestroy A & B of () is not called, then in C, send in the A & B in the registration Intent let A & B to receive and own exit.
Reply:
Do you mean to do with broadcasting, jump to C, A and B, like hair broadcasting finish off yourself?
Reply:
Right, let A and B to receive Intent, after receiving their retirement.
Reply:
Can not be added to the jump to c when a clear top of the flag it? ? ?
Reply:
Intent intent = new Intent (B_Activity.this, C_Activity.class);
intent.setFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity (intent);
So? The next test is not, but after the jump to C code using the above can jump back A close B, C, but C jump directly from A and B can not be closed B. . . Bit dizzy
Reply:
In the B to C, when the B finish () the be all right!
Reply:
But A still,
B to C, B and A are time should finish off
Reply:
When starting C Activity, use FLAG_ACTIVITY_CLEAR_TOP Activity A and B to clear the backStack:
intent = new Intent (context, C.class);
intent.addFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity (intent);
Reply:
Try, seemingly not
Reply:
With the result try it. Start at the ab startresult, bc when finish off b, before finish setresult to a.
So too pulled out. How do you want to achieve something, you need this operation?
Reply:
A B can be written above two Activity:
public static A instance;
Then write in C above:
A.instance.finish ();
Reply:
Product Manager needs to get the metamorphosis ah ~ ~ ~ This can try, Thanks
Reply:
I remember that there is a relevant activity manager class that can be used to manage multiple activity, the landlord can demand.
Reply:
Solutions and more. 11 F and 13 F are good. Just one will do.
Reply:
C B to jump, I do not jump from B, the jump from A.
B first finish off himself, with the return that value, then A receives after the jump C, while finish off their own
Reply:
Put your code to achieve this functionality related posts, okay?
Reply:
B start C when it starts A. Set an action. A judge in the code under the action exit, did not try, but felt OK
Reply:
Write a class that inherits Application class is used to manage the Activity List, you can achieve a close multiple Activity
public class CustomApplication extends Application {
/ ** Save all Activity has been created * /
private Listactivities;
@ Override
public void onCreate () {
super.onCreate ();
init ();
}
public void init () {
/ * Initialize * /
if (activities == null) {
activities = new Vector();
}
}
/ ** The Activity join * /
public synchronized void register (Activity activity) {
activities.add (activity);
}
When / ** Activity is destroyed, removed from Activities in * /
public synchronized void unregister (Activity activity) {
if (activities.size ()! = 0) {
activities.remove (activity);
if (! activity.isFinishing ()) {
activity.finish ();
}
}
}
/ **
* Remove all currently created Activiy, and one by one destroyed
* /
public synchronized void removeAll () {
if (activities.size ()! = 0) {
Activity activity = null;
Iteratoriterator = activities.iterator ();
while (iterator.hasNext ()) {
activity = iterator.next ();
if (! activity.isFinishing ()) {
activity.finish ();
iterator.remove ();
}
}
}
}
/ **
* Jump to page
C* /
public static void intent2C (CustomApplication app, Context ctx) {
app.removeAll ();
System.gc ();
Intent intent = new Intent (ctx, CActivity.class);
ctx.startActivity (intent);
}
}
The management needs to be added to list of Activity inside
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_a);
CustomApplication app = (CustomApplication) getApplication ();
app.register (this);
}
Manifest label under which application to add a name attribute on OK
android: name = "test.xxx.CustomApplication"
android: icon = "@ drawable / icon"
android: label = "@ string / app_name"
android: theme = "@ style / AppTheme">
Reply:
Here is a complete solution:
http://developer.android.com/design/patterns/navigation.html # up-vs-back
Reply:
You can use ActivityGroup to achieve the effect you want.
Reply:
19th floor supports a complete solution here:
http://developer.android.com/design/patterns/navigation.html # up-vs-back
Reply:
Similar problems, come to study under.
No comments:
Post a Comment